RE: can't download excel file correctly
Is there any chance this is an .xlsx (office 2007) and not an xls document? .xlsx documents are really zip files. If this is the case then your content type would be different as well. I believe the .xlsx is: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Hope this helps. -Nate Nathan Sarr Senior Software Engineer River Campus Libraries University of Rochester Rochester, NY 14627 (585) 275-0692 -Original Message- From: raygrrr [mailto:rayg...@gmail.com] Sent: Wednesday, October 19, 2011 5:18 AM To: user@struts.apache.org Subject: can't download excel file correctly Dear Experts, I have this action class to perform file downloading function, however, it doesn't export excel file correctly, it give me a 'actionClassName.zip' file instead of the excel file, but other format files like pdf file, jpg file and text file are fine though, can't figure it out why My action class code: public class DownloadDocumentAction extends Action { private static Log log = LogFactory.getLog(DownloadDocumentAction.class); public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { try { String token = OpenkmUtils.getToken(); byte[] localFile = OpenkmUtils.getFile(token, okmPath); ServletOutputStream out = response.getOutputStream(); InputStream in = new ByteArrayInputStream(localFile); byte[] buffer = new byte[1024]; int length = -1; while((length = in.read(buffer)) != -1) { out.write(buffer, 0, length); } in.close(); out.flush(); out.close(); } catch (java.io.IOException ex) { log.error(ex.getMessage()); } response.setContentType(application/vnd.ms-excel); response.setHeader(Content-Disposition,attachment;filename=\ + fileName+\); return null; } } -- View this message in context: http://struts.1045723.n5.nabble.com/can-t-download-excel-file-correctly-tp4917014p4917014.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
XSS Vulnerability in Struts 2 before 2.2.3
Hello, I noticed the solution mentions turning off DMI support in struts.xml. Would the same result be achieved by setting it in the struts.properties file: # don't allow dynamic method invocation struts.enable.DynamicMethodInvocation = false Thanks, -Nate
RE: XSS Vulnerability in Struts 2 before 2.2.3
I did a quick test and it appeared to work correctly. -Nate -Original Message- From: Maurizio Cucchiara [mailto:maurizio.cucchi...@gmail.com] Sent: Wednesday, May 11, 2011 12:37 PM To: Struts Users Mailing List Subject: Re: XSS Vulnerability in Struts 2 before 2.2.3 I did not checked before, but I bet it works (Please Let us know if it doesn't). On 11 May 2011 16:47, Sarr, Nathan ns...@library.rochester.edu wrote: Hello, I noticed the solution mentions turning off DMI support in struts.xml. Would the same result be achieved by setting it in the struts.properties file: # don't allow dynamic method invocation struts.enable.DynamicMethodInvocation = false Thanks, -Nate -- Maurizio Cucchiara - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Upgrade to Struts 2.2.1 - XWork 2.2.1 vs Xwork 2.2.0
Hello, I was wondering if someone could help me out with the Struts 2.2.1 dependency list. It looks like struts 2.2.1 depends on XWork 2.1.6. However the release notes for Strtus 2.2.1 recommend using XWork 2.2.0. I couldn't find XWork 2.2.0 but could find XWork 2.2.1. Is it recommended to upgrade to XWork 2.2.1 and Ognl 3.0 to fix the critical XWork vulnerability fixed in Stuts 2.2.1? Thanks in advance for the help. -Nate
RE: Upgrade to Struts 2.2.1 - XWork 2.2.1 vs Xwork 2.2.0
Ok, good news. Thanks so much for the note. -Nate From: Gena Ganebnyi [mailto:gganeb...@nebulent.com] Sent: Sat 11/13/2010 2:36 PM To: Struts Users Mailing List Subject: Re: Upgrade to Struts 2.2.1 - XWork 2.2.1 vs Xwork 2.2.0 My Maven Eclipse pluing tells me that struts2-core-2.2.1 depends on xwork-core-2.2.1. On Sat, Nov 13, 2010 at 8:36 PM, Sarr, Nathan ns...@library.rochester.eduwrote: Hello, I was wondering if someone could help me out with the Struts 2.2.1 dependency list. It looks like struts 2.2.1 depends on XWork 2.1.6. However the release notes for Strtus 2.2.1 recommend using XWork 2.2.0. I couldn't find XWork 2.2.0 but could find XWork 2.2.1. Is it recommended to upgrade to XWork 2.2.1 and Ognl 3.0 to fix the critical XWork vulnerability fixed in Stuts 2.2.1? Thanks in advance for the help. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Is Using Spring With Struts 2 A Good Idea?
Hi Bruce, We have been working with Struts 2 and Spring here for a couple of years (we went production a few months ago) and I have found it to work together quite well for us - we use it for Dependency injection as well as to tie in with Hibernate, Quartz. We use some sub projects including Spring Security and Spring LDAP. If you are curious can see the site in action here: https://urresearch.rochester.edu/home.action Best, -Nate Nathan Sarr Senior Software Engineer River Campus Libraries University of Rochester Rochester, NY 14627 (585) 275-0692 -Original Message- From: phillips1021 [mailto:bphill...@ku.edu] Sent: Wednesday, November 25, 2009 11:29 AM To: user@struts.apache.org Subject: Is Using Spring With Struts 2 A Good Idea? At the University of Kansas (#1 college basketball team :) we use Struts 2 for our web application framework. Its worked very well for us. I've been learning the Spring framework and how to use it with Struts 2. I think the two frameworks work very well together. I'm preparing a class for the other Java developers on how to use Struts 2 and Spring together. As part of my research I'd like to hear from other Struts 2 developers on if you use Spring with Struts 2 and if you think its a good or bad practice. Thanks in advance for any feedback you can provide on why or why not it's a good idea to use Struts 2 with Spring. Bruce Phillips http://www.brucephillips.name/blog http://www.brucephillips.name/blog -- View this message in context: http://old.nabble.com/Is-Using-Spring-With-Struts-2-A-Good-Idea--tp26515837p26515837.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Need help writing an interceptor to force a user to change their password
Hi Russ, You may want to try creating a global result in your struts.xml: global-results result name=change-password/pages/user/login/force_change_password.jsp/result /global-results Then in your interceptor return the result name change-password That is how we accomplished something similar to your pblem. Hope this helps. -Nate From: Russell Neufeld [mailto:russ.neuf...@hds.com] Sent: Mon 6/29/2009 5:19 PM To: Struts Users Mailing List Subject: Need help writing an interceptor to force a user to change their password Hi all, I'm trying to implement functionality which will force a user to a change-password page if a certain bit is set on their user account. That is, no matter what action they are attempting to take, I'd like to intercept the request and show them a change-password page. I've written a few struts2 interceptors before, but this one has me stumped. I can easily get the user principal object and see whether or not I need to insert the change-password page, but I'm not sure what to do next. I was thinking about trying to change the action object to one which would simply return a string pointing to the change-password jsp, but I don't know how to replace the action object on the invocation object (and that doesn't seem like a good idea). I'd prefer not to solve this with a redirect because I'd like to use some of the context of current request in the rendering of the change-password page. Any ideas? Thanks, Russ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: [OT] What slows you down?
Let me start with I think struts 2 is great - like some of the others the size of the technology stack and UI seem to give me the most trouble as well. Some things I've had to deal with in struts 2 are: 1. The tags - I decided to not use the struts tags as I prefer to use JSTL and JSP EL as they allow me to style the pages as needed and there seemed to be some overlap in the functionality - I had to also write my own JSP tag to get errors out of action errors so I could place specific messages in any location I needed. I tried extending the tags but they gave me some trouble so instead I created tags by extending SimpleTagSupport which was much easier for me. 2. Validation - since I'm using Yahoo User Interface Libraries (YUI) and my actions are returning JSON or HTML fragments returning INPUT didn't really work out so I removed validation in favor of doing it in the ActionSupport class. I'm not sure if there is much struts can do about this one. 3. I'd have to say I've stayed away from ognl in favor of JSP el. I'm not sure if the above is due to some of my misunderstanding but above are some of the things I ran into. The above is small in comparison to what struts saves me in terms of time by using Interceptors, populating my classes for me and placing data on the request. -Nate -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ted Husted Sent: Friday, June 20, 2008 7:43 AM To: Struts Users Mailing List Subject: [OT] What slows you down? Since it's friday, let me pose a question to the group ... Even with rock-solid frameworks like Apache Struts, it still seems like web application development takes longer than it should. Some frameworks, like Ruby on Rails, speak directly to time to market concerns and have been gathering many followers. But why does web application still seem so difficult or so time-consuming? Are there time bandits that still suck days or weeks out of your development schedule? Are there time gremlins that nickel-and-dime you every hour of every day? Is there anything more that frameworks like Apache Struts can do to help? Or are just there intractable problems with web development itself? Thoughts? :) -Ted. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] What slows you down?
Hi David, That sounds great - thanks for tip. I'm going to grab the Beta release ASAP. -Nate -Original Message- From: Karr, David [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2008 1:47 PM To: Struts Users Mailing List Subject: RE: [OT] What slows you down? -Original Message- From: Sarr, Nathan [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2008 10:29 AM To: Struts Users Mailing List Subject: RE: [OT] What slows you down? 2. Validation - since I'm using Yahoo User Interface Libraries (YUI) and my actions are returning JSON or HTML fragments returning INPUT didn't really work out so I removed validation in favor of doing it in the ActionSupport class. I'm not sure if there is much struts can do about this one. Note that in the upcoming 2.1.x release you can use the jsonValidationWorkflowStack and automatically get action errors directly in your JSON results, using the validation framework out of the box. There's even a very small JavaScript module that integrates with what's expected to be there using the Struts tags, so you can do your submit and display of errors entirely with the Ajax request. You could then use the exact same form and do a regular non-Ajax submit and do the exact same validations (if you wanted to). I verified this with a simple test case, using YUI 2.5.2 and Struts2 2.1.2. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Interceptor Stack Help
Hello, I have been having a little trouble with the interceptor stack but I have quite a bit of info, so I'm hoping someone can help me out. Here it goes: I created my own interceptor stack with the following: [code] interceptor-stack name=crudStack interceptor-ref name=token/ interceptor-ref name=servletConfig/ interceptor-ref name=staticParams/ interceptor-ref name=params/ interceptor-ref name=user/ --- Note this interceptor interceptor-ref name=prepare/ interceptor-ref name=modelDriven/ interceptor-ref name=params/ interceptor-ref name=conversionError/ interceptor-ref name=validation/ interceptor-ref name=workflow/ /interceptor-stack [/code] The user interceptor which I created puts the user into the value stack. However I noticed for some forms the xwork validation RequiredStringValidator started failing even though the input was valid. For example, the following form fails validation [shortened for explanation purposes]: [code] !-- Form to save a collection name -- s:form method=post s:textfield label=%{getText('name')} name=collectionName/ /s:form [/code] However this form works [shortened for explanation purposes]: !-- Form to save a language type -- s:form method=post s:textfield label=%{getText('name')} name=languageType.name/ /s:form Notice the difference is the first one I am setting the value directly on the action where in the second form, I am setting a value on an object within the action. Furthermore, When I change the stack to the following both forms work: [code] interceptor-stack name=crudStack interceptor-ref name=token/ interceptor-ref name=servletConfig/ interceptor-ref name=staticParams/ interceptor-ref name=params/ interceptor-ref name=prepare/ interceptor-ref name=modelDriven/ interceptor-ref name=params/ interceptor-ref name=conversionError/ interceptor-ref name=validation/ interceptor-ref name=workflow/ interceptor-ref name=user/ --- Moved interceptor to bottom of stack /interceptor-stack [/code] I did some more digging and I found the difference is: When ognl is able to find the value itself in the tree for the validator a string rather than an array with a single value is retuned causing the validation to pass. So when ognl.java executes the following method: [code] public static Object getValue( Object tree, Map context, Object root, Class resultType ) throws OgnlException { Object result; OgnlContext ognlContext = (OgnlContext)addDefaultContext(root, context); result = ((Node)tree).getValue( ognlContext, root ); if (resultType != null) { result = getTypeConverter( context ).convertValue( context, root, null, null, result, resultType); } return result; } [/code] For the SECOND form, which passes, the code: result = ((Node)tree).getValue( ognlContext, root ); finds a value and returns however, for the FIRST form, which fails, ognl gets a null from: result = ((Node)tree).getValue( ognlContext, root ); and executes then executes: result = getTypeConverter( context ).convertValue( context, root, null, null, result, resultType); which is actually a call to: com.opensymphony.xwork2.util.XWorkMapPropertyAccessor.getProperty(Map context, Object target, Object name) which delegates to its parent class method: ognl.MapPropertyAccessor.getProperty(context, target, name) Now, this actually finds the value and returns it as a string array with a single value. It returns this array to the RequiredStringValidator so in the validate(Object object) method the following code evaluates to true because a String[] is not an instance of String: [code] if (!(value instanceof String)) { addFieldError(fieldName, object); } [/code] If you have any thoughts, they would be greatly appreciated. Thanks again, -Nate
Struts 2 - Action writing to response output stream
Hello, We are using some actions to write directly to the stream for some ajax based functionality. To do this I wrote a NoOp result type that does nothing. [code] public class NoOp extends StrutsResultSupport { public NoOp() { super(); } protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { //no op } } [/code] This allows the action to write the content using: response.getOutputStream().write(contents) I am looking for best practices. Is this an acceptable way to do this or is there a better way to allow an action to return content that I would like placed as only part of the page? Thanks for the help, Nathan Sarr
RE: Struts 2 - Action writing to response output stream
Excellent, Thanks for the help musachy - much appreciated. -Nate -Original Message- From: Musachy Barroso [mailto:[EMAIL PROTECTED] Sent: Friday, March 30, 2007 10:27 AM To: Struts Users Mailing List Subject: Re: Struts 2 - Action writing to response output stream You can just write to the outputstream, and return null from execute, and you won't need a NoOp result. I also wrote my own NoOp result when i started using S2 ;). Maybe this should be on the FAQs. musachy On 3/30/07, Sarr, Nathan [EMAIL PROTECTED] wrote: Hello, We are using some actions to write directly to the stream for some ajax based functionality. To do this I wrote a NoOp result type that does nothing. [code] public class NoOp extends StrutsResultSupport { public NoOp() { super(); } protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { //no op } } [/code] This allows the action to write the content using: response.getOutputStream().write(contents) I am looking for best practices. Is this an acceptable way to do this or is there a better way to allow an action to return content that I would like placed as only part of the page? Thanks for the help, Nathan Sarr -- Hey you! Would you help me to carry the stone? Pink Floyd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Howto Construct Editable Tree
Hi Pete, You might want to try http://www.jenkov.com/prizetags/introduction.tmpl They have a tree tag that I have found very useful. Best, -Nate -Original Message- From: Peter Neu [mailto:[EMAIL PROTECTED] Sent: Monday, March 19, 2007 9:43 AM To: user@struts.apache.org Subject: Howto Construct Editable Tree Hello, I have a hierarchically organized data object which I need to display. The user may edit some of its attributes. I figured it must be a tree like structure with editable nodes. Is there an easy way to do this in Struts 1.x? I'm not very good at writing JavaScript code. :o( Has anybody done this before? Cheers, Pete - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Howto Construct Editable Tree
Hi Pete, Unfortunately, I've never actually had to edit the nodes - however for displaying a tree it was one of the best I found. The user guide can be found here: http://www.jenkov.com/projects/prizetags/download/Tree_Tag_User_Guide.pdf There may be better tree implementations for editing - however I had a hard time finding any tree implementations. You may want to post to the form and see if anyone has had to edit the nodes before: http://www.jenkov.com/forum/listThreads.ctrl?forumId=0 Best, -Nate -Original Message- From: Peter Neu [mailto:[EMAIL PROTECTED] Sent: Monday, March 19, 2007 10:18 AM To: 'Struts Users Mailing List' Subject: AW: Howto Construct Editable Tree Hi, Looks good - can you edit the nodes? Cheers, Pete -Ursprüngliche Nachricht- Von: Sarr, Nathan [mailto:[EMAIL PROTECTED] Gesendet: Montag, 19. März 2007 15:09 An: Struts Users Mailing List Betreff: RE: Howto Construct Editable Tree Hi Pete, You might want to try http://www.jenkov.com/prizetags/introduction.tmpl They have a tree tag that I have found very useful. Best, -Nate -Original Message- From: Peter Neu [mailto:[EMAIL PROTECTED] Sent: Monday, March 19, 2007 9:43 AM To: user@struts.apache.org Subject: Howto Construct Editable Tree Hello, I have a hierarchically organized data object which I need to display. The user may edit some of its attributes. I figured it must be a tree like structure with editable nodes. Is there an easy way to do this in Struts 1.x? I'm not very good at writing JavaScript code. :o( Has anybody done this before? Cheers, Pete - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Interceptor + putting information on the request
Hello, I am using struts 2.0.6. I wrote an interceptor to use with Acegi security to place the UserDetails object on the request so I could access it on my JSP page. However when I tried to access the object on the page, it was not found. I then instead placed it on the session using the following which worked: [code] final ActionContext context = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST); HttpSession session = request.getSession(); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if(auth != null) { if(auth.getPrincipal() instanceof UserDetails) { IrUser user = (IrUser)auth.getPrincipal(); session.setAttribute(user, user); } } return invocation.invoke(); [/code] I was wondering is there any way to place this information on the request in an interceptor. Thanks for the help. -Nate
RE: Interceptor + putting information on the request
Hi Matt, Thanks very much, that fixed it. -Nate - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]