RE: Multiple forms in JSP using struts
I've never liked this since I've always thought that, if one uses this approach, as soon as one of those forms requires remembering its values, all (action)forms (including that one) are forced to having session scope (then you'd have to setup a garbage collection process for those session forms). Am I right? F. -Mensaje original- De: Koushik [mailto:[EMAIL PROTECTED] Enviado el: viernes, 05 de noviembre de 2004 8:23 Para: Struts Users Mailing List Asunto: Re: Multiple forms in JSP using struts U can use multiple forms in ur jsp and for each action in ur form,i.e. when u r posting it, u need to have a separate set of mappings in the struts-config.xml. - Original Message - From: Asim Ghosh [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 05, 2004 12:45 PM Subject: Multiple forms in JSP using struts hello all, how can i manage multiple forms in on jsp using struts. In struts-config.xml can I mention two form names in action. If no how can this be achieved ? Regards, Asim - ALL-NEW Yahoo! Messenger - all new features - even more fun! - 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: Multiple forms in JSP using struts
I agree with u that Action Forms should not session scoped unless required but i guess the question was whether u can use mulitple forms in jsp,i.e. html:form. I hope i have guess it right? - Original Message - From: Freddy Villalba A. [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, November 05, 2004 1:42 PM Subject: RE: Multiple forms in JSP using struts I've never liked this since I've always thought that, if one uses this approach, as soon as one of those forms requires remembering its values, all (action)forms (including that one) are forced to having session scope (then you'd have to setup a garbage collection process for those session forms). Am I right? F. -Mensaje original- De: Koushik [mailto:[EMAIL PROTECTED] Enviado el: viernes, 05 de noviembre de 2004 8:23 Para: Struts Users Mailing List Asunto: Re: Multiple forms in JSP using struts U can use multiple forms in ur jsp and for each action in ur form,i.e. when u r posting it, u need to have a separate set of mappings in the struts-config.xml. - Original Message - From: Asim Ghosh [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 05, 2004 12:45 PM Subject: Multiple forms in JSP using struts hello all, how can i manage multiple forms in on jsp using struts. In struts-config.xml can I mention two form names in action. If no how can this be achieved ? Regards, Asim - ALL-NEW Yahoo! Messenger - all new features - even more fun! - 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]
Re: Using Tiles outside of an ActionServlet
Doh - I guess I wasn't clear enough. I want to have the Requests for the html pages (Section2) forwarded to a standardLayout page which uses tiles to provide consistent screens. The originally targetted html page needs to be included/embedded within the standardLayout page. David, I guess I could be missing something (wouldn't be the first time), but I don't think your solution will give me that will it? Its more about allowing the html files to themselves contain a tile. If I could somehow get the html requests to be forwarded to a single page, then I could do it. But I can't see how to do this without using a 2nd ActionServlet which brings me back in the original pain. William - Original Message - From: David G. Friedman [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, November 05, 2004 3:35 PM Subject: RE: Using Tiles outside of an ActionServlet William, For Section 2, IF you are using the same webapp, you can make a tile show up in a JSP without using the Actionservlet (you just need to have the Struts plugIn initialize the tiles from the tiles xml configuration. Try creating a JSP with this type of syntax: %@ taglib uri=/WEB-INF/tiles.tld prefix=tiles % tiles:insert definition=loginDef/ Now, to get the *.html mapping to work, you'd have to reonfigure yout application server to map *.html pages so they are handled by the JSP engine. In tomcat, you can do that like this: servlet-mapping servlet-namejsp/servlet-name url-pattern*.jsp/url-pattern /servlet-mapping Regards, David -Original Message- From: William Ferguson [mailto:[EMAIL PROTECTED] Sent: Thursday, November 04, 2004 10:36 PM To: [EMAIL PROTECTED] Subject: Using Tiles outside of an ActionServlet I'm trying to create a WebApp with 2 sections. Section1 consists of Struts Actions managed by an ActionServlet and using Tiles for consistent layout. The incoming requests will always be '*.do'. Section2 is a bunch of generated html fragments (each is a page's worth) that I would like to embed in the Tiles I'm already using in Section1. Ie Request for html page comes in and it is forwarded to the Tile page which embeds the originally requested page. The incoming requests will always be 'foo/htmlpagename.html' I thought I had it nailed. Attempt1: Have the request for Section2 be handled by its own ActionServlet, with a very simple custom RequestProcessor. But Struts only allows a single instance of ActionServlet (or subclass) within a WebApp. Atempt2: Use a single ActionServlet and either use a separate Module for each section, or use a wildcard ActionMapping to catch all of Section2's html requests. But Struts only allows a single servlet-mapping element for the controller-servlet and I would need 2 (*.do and foo/*.html). NB further Struts restriction is that when using Modules you can only use extension paths in your servlet-mappings. Attempt3: ??? I'm looking for ideas. At the moment the only solution I can see is to implement my own Servlet (not an ActionServlet subclass) which then uses the Tiles config and mechanism to render the Section2 response with the required layout. Is there a better way? thanks in advance. William - 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: Struts Best Practices
I am handling a web project and using struts framework. Can any one tell me where to find stuff on Struts Best Practices or Desgin and Coding Standards for a struts Application. There are couple of good articles that I found useful when I was building my first struts based project. I've put ratings as stars according to my personal belief. 1) http://www.javaworld.com/javaworld/jw-09-2004/jw-0913-struts_p.html 2) http://www.onjava.com/lpt/a/2832 * 3) http://www-106.ibm.com/developerworks/web/library/wa-struts/?ca=dnt-52 4 *** 4) http://www.husted.com/struts/tips/ 5) http://www.reumann.net/struts/main.do (Tutorial) * 6) http://struts.apache.org/faqs/indexedprops.html *** 7) http://struts.apache.org/userGuide/dev_validator.html * HTH. Regards, Kinjal Sonpal - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple input forms - one action - one validator, how?
Hello, I have multiple forms that point to the same action. It is not a multipage form, it is done as different types of searches done on different pages) and I would like to validate the forms individually using the validate() method on the form bean. However, I am required to define an input= parameter for the action for the validation, and since the input pages can be different. I can solve this problem by having a different action name for each search page and make them point to the same action class, but is there a nicer solution for this? Thanks, Can - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple input forms - one action - one validator, how?
If you want different types of validation to be performed before the Action is executed, then assuming you are using the Struts Validator I recommend that you : 1) ensure your Forms extend from ValidatorActionForm, 2) Create separate ActionMappings for each type of validation you want to perform (each ActionMapping uses the same Action class). 3) Create the various validation specifications in validation.xml, each keyed to the new ActionMappings. William - Original Message - From: Can Gencer [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, November 05, 2004 9:10 PM Subject: Multiple input forms - one action - one validator, how? Hello, I have multiple forms that point to the same action. It is not a multipage form, it is done as different types of searches done on different pages) and I would like to validate the forms individually using the validate() method on the form bean. However, I am required to define an input= parameter for the action for the validation, and since the input pages can be different. I can solve this problem by having a different action name for each search page and make them point to the same action class, but is there a nicer solution for this? Thanks, Can - 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: Need an alternative to bean:define
As an FYI. I don't think it is wise to say that the Struts taglibs will be going away. I am of the opinion that they will be around for quite some time. At least until JSF is adopted considered as the default choice for all new web development. On a somewhat related note, do you even know how many hours I spent creating those taglib tests? ;) -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: Eddie Bush [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, November 04, 2004 11:43 PM Subject: Re: Need an alternative to bean:define My condolences :-( I now see your rock and hard spot. It's not about bleeding edge though. Of course, what counts in that regard is your clients' opinion of what bleeding edge is. Best of luck! Eddie - Original Message - From: Janice [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, November 04, 2004 12:25 PM Subject: RE: Need an alternative to bean:define I should point out that it isn't my company that has the restrictions. My employer would quite happily move to the bleeding edge of any technology if there were any benefit to do so. In this case the client has very definite parameters we need to work within. Their servers are set up in a certain way and they have standards that must be followed or else we don't get paid. I don't have to agree with their standards in order to take their money. ;) Thanks for the input all the same. J -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 03, 2004 5:17 PM To: Struts Users Mailing List Subject: Re: Need an alternative to bean:define I would question anyone who told me I had to use something that is going away in the future (most of Struts' taglibs), instead of using a standard technology (the JSTL). Are they fully-aware of the decision they're making? Are you running within a container that supports Servlet Specification 2.3 and JSP Specification 1.2? I can't conceive of anyone being so narrow-minded. If I told my boss I wanted to use the JSTL over Struts' taglibs (a conversation that would never take place because I'm able to do whatever I feel is best), citing that the JSTL was a standard technology and that the Struts taglibs would be going away, he'd thank me for the FYI and tell me to do what I felt was best. We're very into using standards-compliant methodologies where it makes sense to do so though. Eddie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0445-1, 11/03/2004 Tested on: 11/4/2004 10:43:32 PM avast! - copyright (c) 2000-2004 ALWIL Software. http://www.avast.com - 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: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue
I think that it is unusual to directly include Struts actions in JSP files. When composing pages of different parts, Tiles is the much more common approach. The standard usage of Tiles is to include JSP files directly, but you can use tiles to include Struts actions in JSP files. (See Section 5.2 of the Tiles Advanced Features guide, a PDF file, at http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf.) -- Jeff Parke Jeff wrote: I'm still having trouble including a Struts action into a JSP (c:import url=/someAction.do /). I've tried using absolute URLs, passing the jsessionid to ensure that the session is not lost, but the request context is different between the JSP and the included action, so this not suitable for many situations. I've also tried upgrading to Struts 1.2.4. This does not resolve the Response has already been committed issue when including more than one Struts action in a JSP. The app server is using JRE 1.4.1_03-b02. Can anyone tell me whether they have seen this situation before? How common is it? Is it unusual to include Struts actions in JSPs? Anyone? Thanks, Jeff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Re: Need an alternative to bean:define
Many times newer developers don't care so much about the academics of what is proper. For example, they see the Struts tags and like them, and then become attached to them. It can be disconcerting to them to find out that they are using an outdated technology so soon after they have discovered something that made development more efficient and more fun than it had been before. The Java community at large should remain aware of this phenomenon. I say, if a tool is proven to work well for a particular job, it belongs in the box. In the context of programming, this presupposes some level of support and acceptance for the tool in the community. I have been doing Swing/AWT development for about three years now. Over and over again I have implemented the same types of interface devices, scouring the Swing source code, examining stack traces and ever perfecting my use of Threads. I am just now beginning to get good at it. Every time a new Swing release comes out, I can't wait to find out what bugs have been fixed, what new devices are available for Linux that have been taken for granted on Windows, and the like. At the same time I see libraries emerge that promoters claim are the result of Swing's shortcomings, and I mostly find it ridiculous, given the context (time) and my own experience (Swing and Graphics 2D can do all sorts of amazing things). I hope Sun isn't affected much by it and continues on building and documenting Swing. Everyone is in too much of a hurry to go on to the next tool. Programmers who end up building things of substance reach for their trusted tools, devices, paradigms, etc., when they are inspired and want to get something done with confidence. Some of the best Java GUI applications I have seen will run on a (pre-Swing) 1.1 JVM, and here there are people saying Swing is a wash. Based on what I have read as a subscriber to this list, I conclude that many Struts users feel the same way about Struts as I do about Swing. They (myself included) greatly appreciate James' taglib tests, the ongoing efforts to build a better dispatch action and the work of all other contributors (not only committers). They breathe a collective sigh of relief when they see that Craig is writing papers about Struts 2. Erik P.S. This is no attack on Eddie's advice to prefer JSTL to the Struts tags. I often give the same advice. James Mitchell wrote: As an FYI. I don't think it is wise to say that the Struts taglibs will be going away. I am of the opinion that they will be around for quite some time. At least until JSF is adopted considered as the default choice for all new web development. On a somewhat related note, do you even know how many hours I spent creating those taglib tests? ;) -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: Eddie Bush [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, November 04, 2004 11:43 PM Subject: Re: Need an alternative to bean:define My condolences :-( I now see your rock and hard spot. It's not about bleeding edge though. Of course, what counts in that regard is your clients' opinion of what bleeding edge is. Best of luck! Eddie - Original Message - From: Janice [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, November 04, 2004 12:25 PM Subject: RE: Need an alternative to bean:define I should point out that it isn't my company that has the restrictions. My employer would quite happily move to the bleeding edge of any technology if there were any benefit to do so. In this case the client has very definite parameters we need to work within. Their servers are set up in a certain way and they have standards that must be followed or else we don't get paid. I don't have to agree with their standards in order to take their money. ;) Thanks for the input all the same. J -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 03, 2004 5:17 PM To: Struts Users Mailing List Subject: Re: Need an alternative to bean:define I would question anyone who told me I had to use something that is going away in the future (most of Struts' taglibs), instead of using a standard technology (the JSTL). Are they fully-aware of the decision they're making? Are you running within a container that supports Servlet Specification 2.3 and JSP Specification 1.2? I can't conceive of anyone being so narrow-minded. If I told my boss I wanted to use the JSTL over Struts' taglibs (a conversation that would never take place because I'm able to do whatever I feel is best), citing that the JSTL was a standard technology and that the Struts taglibs would be going away, he'd thank me for the FYI and tell me to do what I felt was best. We're very into using standards-compliant methodologies where it makes sense to do so though. Eddie
Re: Struts Best Practices
hi rajagopal, dynaforms are useful for putting something together quickly, but I find them less useful than hardcoded form classes sometimes, especially if there are many form fields. The way to access some data from the form submit in your action is usually so for a dynaform: addressDTO.setLine3((String) accommForm.get(line3)); and for a hard-coded formbean: addressDTO.setLine3(accommForm.getLine3()); If find that the hard-coded formbean is easier to code with in IDEs like Eclipse, due to better auto-completion, less room for typo mistakes etc. hth Adam On 11/05/2004 06:32 AM Y, Rajagopal wrote: Ok...Fine.. In DynaActionForm we create all properteis in configuration file. and the default scope of the form is session(i believe). if we have a form that is created dynamically on the first page (Say only 2 fields (name Pwd)), isn't it overhead to carry the object which contains field properties which is not required for the particular form? Hope i am clear what i mean !!! Can u pls clear my doubt... Regds Rajagopal -Original Message- From: Koushik [mailto:[EMAIL PROTECTED] Sent: Friday, November 05, 2004 11:59 AM To: Struts Users Mailing List Subject: Re: Struts Best Practices With the help of DynaActionForm u can create your form dynamically. for example if u r building a Purchase Order form where there are multiple line items,the above is best suitable to dynamically generate your form - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Using Tiles outside of an ActionServlet
If you are only serving HTML pages and want to wrap them in your standard layout, forget tiles and check out SiteMesh: www.opensymphony.com/sitemesh The Tiles mapping I suggested can do more complex things for you than SiteMesh. It would require setting up a tiles controller. They are explained well, and with examples, in the Tiles Advanced Features PDF. See the Struts' site's UserGuide on Tiles for a link at the bottom of the page to that PDF. Regards, David -Original Message- From: William Ferguson [mailto:[EMAIL PROTECTED] Sent: Friday, November 05, 2004 5:39 AM To: Struts Users Mailing List Subject: Re: Using Tiles outside of an ActionServlet Doh - I guess I wasn't clear enough. I want to have the Requests for the html pages (Section2) forwarded to a standardLayout page which uses tiles to provide consistent screens. The originally targetted html page needs to be included/embedded within the standardLayout page. David, I guess I could be missing something (wouldn't be the first time), but I don't think your solution will give me that will it? Its more about allowing the html files to themselves contain a tile. If I could somehow get the html requests to be forwarded to a single page, then I could do it. But I can't see how to do this without using a 2nd ActionServlet which brings me back in the original pain. William - Original Message - From: David G. Friedman [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, November 05, 2004 3:35 PM Subject: RE: Using Tiles outside of an ActionServlet William, For Section 2, IF you are using the same webapp, you can make a tile show up in a JSP without using the Actionservlet (you just need to have the Struts plugIn initialize the tiles from the tiles xml configuration. Try creating a JSP with this type of syntax: %@ taglib uri=/WEB-INF/tiles.tld prefix=tiles % tiles:insert definition=loginDef/ Now, to get the *.html mapping to work, you'd have to reonfigure yout application server to map *.html pages so they are handled by the JSP engine. In tomcat, you can do that like this: servlet-mapping servlet-namejsp/servlet-name url-pattern*.jsp/url-pattern /servlet-mapping Regards, David -Original Message- From: William Ferguson [mailto:[EMAIL PROTECTED] Sent: Thursday, November 04, 2004 10:36 PM To: [EMAIL PROTECTED] Subject: Using Tiles outside of an ActionServlet I'm trying to create a WebApp with 2 sections. Section1 consists of Struts Actions managed by an ActionServlet and using Tiles for consistent layout. The incoming requests will always be '*.do'. Section2 is a bunch of generated html fragments (each is a page's worth) that I would like to embed in the Tiles I'm already using in Section1. Ie Request for html page comes in and it is forwarded to the Tile page which embeds the originally requested page. The incoming requests will always be 'foo/htmlpagename.html' I thought I had it nailed. Attempt1: Have the request for Section2 be handled by its own ActionServlet, with a very simple custom RequestProcessor. But Struts only allows a single instance of ActionServlet (or subclass) within a WebApp. Atempt2: Use a single ActionServlet and either use a separate Module for each section, or use a wildcard ActionMapping to catch all of Section2's html requests. But Struts only allows a single servlet-mapping element for the controller-servlet and I would need 2 (*.do and foo/*.html). NB further Struts restriction is that when using Modules you can only use extension paths in your servlet-mappings. Attempt3: ??? I'm looking for ideas. At the moment the only solution I can see is to implement my own Servlet (not an ActionServlet subclass) which then uses the Tiles config and mechanism to render the Section2 response with the required layout. Is there a better way? thanks in advance. William - 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]
How use the BeanUtils and interface converts
Hi, I'd like know how I can use BeanUtils.copyProperties(form, model), when I my objects have name equals but types noequals, example, in my form I have a attribuite named dateInsert of type string, but in my model I have this attribuite of the type java.util.Date. How I specified to BeanUtils this type of conversion. I read some articles in internet saw that I can implements a inteface converter, but i don't know use. SomeBody can hope me, with link or example use this classe??? Thanks folks, -- Gabriel França Campolina Sun Certified Programmer for the Java 2 Plataform - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How use the BeanUtils and interface converts
Writing a date converter is pretty simple; the only reason there isn't one included in the beanutils distribution is that there's not a very easy way to configure the date format in a universal way. Below is an example. This one is implemented as a static inner class within the only class which uses it, but you could do it differently: static class SimpleDateFormatDateConverter implements org.apache.commons.beanutils.Converter { String dateFormat = null; SimpleDateFormatDateConverter(String dateFormat) { this.dateFormat = dateFormat; } public Object convert(Class clazz, Object obj) { if (obj == null) return null; if (obj instanceof java.util.Date) return obj; String toParse = obj.toString(); if (toParse.trim().length() == 0) return null; java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat(dateFormat); try { return fmt.parse(obj.toString()); } catch (Exception ex) { throw new org.apache.commons.beanutils.ConversionException(ex); } } } Then, elsewhere in your Java code, you would register the converter doing something like this: String dateFormat = -MM-dd; ConvertUtils.register(new SimpleDateFormatDateConverter(dateFormat), java.util.Date.class); Since this code was written, beanutils has made good progress away from using static methods for everything, which makes it easier to have Converters in different parts of your app that behave differently. See http://jakarta.apache.org/commons/beanutils/api/index.html and more specifically http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils/BeanUtilsBean.html#BeanUtilsBean(org.apache.commons.beanutils.ConvertUtilsBean,%20org.apache.commons.beanutils.PropertyUtilsBean) for the doc details. Joe At 12:13 PM -0300 11/5/04, Gabriel França Campolina wrote: Hi, I'd like know how I can use BeanUtils.copyProperties(form, model), when I my objects have name equals but types noequals, example, in my form I have a attribuite named dateInsert of type string, but in my model I have this attribuite of the type java.util.Date. How I specified to BeanUtils this type of conversion. I read some articles in internet saw that I can implements a inteface converter, but i don't know use. SomeBody can hope me, with link or example use this classe??? Thanks folks, -- Gabriel França Campolina Sun Certified Programmer for the Java 2 Plataform - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; I'll know I'm in the wrong place. - Carlos Santana
Re: Connection Pooling With Struts
Tomcat can provide a connection pool, you just have to configure the pool and look up the resource in your application. The details can be found here : http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Tushar Agrawal wrote: Hi Freinds, I am using struts-config default connection pooling with mysql. In future we may migrate to Oracle or SQL Server 2000 . Can you please tell me the best way of implementing connection pooling in struts with database as MySQL and Oracle 9i. Thanks Tushar Agrawal - Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com/a - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue
Thanks for the information, Jeff. Unfortunately, though the Tiles Advanced Features Guide indicates it is possible to include multiple Struts actions (using tiles:insert) on one page, I _still_ get the IllegalStateException Response has already been committed. We often need to prepare data to be shown by a JSP page. In the MVC framework, the controller prepares data (in the model) to be shown by the view. Translated to Tiles and Struts, we can use a Struts Action as a controller, a JSP page as a view, and combine both in a Tile. So, when you insert the Tile, the Action is called before the JSP page is displayed. Now, your complex web page can be made of Tiles fed by controllers (one sub-controller for each Tile). This approach is better than one single controller for all Tiles of the page, because it really allows building autonomous Tiles, without worrying about how to fed (sic) them all. - Tiles Advanced Features Guide (http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf) This is describing exactly what I want to accomplish and the reason for it but I keep running into the same committed response problem. Is it possible that this is a container issue rather than being a Struts issue? Can someone else confirm that c:import and tiles:insert both cause an IllegalStateException when including more than 1 (actually try 3 or 4) Struts action on the same JSP? Thanks again for anyone who can help, Jeff I think that it is unusual to directly include Struts actions in JSP files. When composing pages of different parts, Tiles is the much more common approach. The standard usage of Tiles is to include JSP files directly, but you can use tiles to include Struts actions in JSP files. (See Section 5.2 of the Tiles Advanced Features guide, a PDF file, at http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf.) -- Jeff Parke Jeff wrote: I'm still having trouble including a Struts action into a JSP (c:import url=/someAction.do /). I've tried using absolute URLs, passing the jsessionid to ensure that the session is not lost, but the request context is different between the JSP and the included action, so this not suitable for many situations. I've also tried upgrading to Struts 1.2.4. This does not resolve the Response has already been committed issue when including more than one Struts action in a JSP. The app server is using JRE 1.4.1_03-b02. Can anyone tell me whether they have seen this situation before? How common is it? Is it unusual to include Struts actions in JSPs? Anyone? Thanks, Jeff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to use getServletConfig( ) outside a Servlet.
Hi. I want to make a static class which access a configuration file in /WEB-INF/. I tried Classname.class.getResourceAsStream(/WEB-INF/config-file.xml); but it wont work. So I thought I have to do it by using getServletConfig().getServletContext( ).getResourceAsStream(/WEB-INF/config-file.xml) but I did not figure out how to do that because getServletCofig only works in Servlets, not in static beans. Can you help me? Thanx in Advance, Lukas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue
Can't really comment on Tiles since I don't use it, but this recent thread may be of interest: http://marc.theaimsgroup.com/?t=10976831933 Quoting Parke Jeff [EMAIL PROTECTED]: Thanks for the information, Jeff. Unfortunately, though the Tiles Advanced Features Guide indicates it is possible to include multiple Struts actions (using tiles:insert) on one page, I _still_ get the IllegalStateException Response has already been committed. We often need to prepare data to be shown by a JSP page. In the MVC framework, the controller prepares data (in the model) to be shown by the view. Translated to Tiles and Struts, we can use a Struts Action as a controller, a JSP page as a view, and combine both in a Tile. So, when you insert the Tile, the Action is called before the JSP page is displayed. Now, your complex web page can be made of Tiles fed by controllers (one sub-controller for each Tile). This approach is better than one single controller for all Tiles of the page, because it really allows building autonomous Tiles, without worrying about how to fed (sic) them all. - Tiles Advanced Features Guide (http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf) This is describing exactly what I want to accomplish and the reason for it but I keep running into the same committed response problem. Is it possible that this is a container issue rather than being a Struts issue? Can someone else confirm that c:import and tiles:insert both cause an IllegalStateException when including more than 1 (actually try 3 or 4) Struts action on the same JSP? Thanks again for anyone who can help, Jeff I think that it is unusual to directly include Struts actions in JSP files. When composing pages of different parts, Tiles is the much more common approach. The standard usage of Tiles is to include JSP files directly, but you can use tiles to include Struts actions in JSP files. (See Section 5.2 of the Tiles Advanced Features guide, a PDF file, at http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf.) -- Jeff Parke Jeff wrote: I'm still having trouble including a Struts action into a JSP (c:import url=/someAction.do /). I've tried using absolute URLs, passing the jsessionid to ensure that the session is not lost, but the request context is different between the JSP and the included action, so this not suitable for many situations. I've also tried upgrading to Struts 1.2.4. This does not resolve the Response has already been committed issue when including more than one Struts action in a JSP. The app server is using JRE 1.4.1_03-b02. Can anyone tell me whether they have seen this situation before? How common is it? Is it unusual to include Struts actions in JSPs? Anyone? Thanks, Jeff -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hi
Hi, I have a logic:iterate tag in my jsp. logic:iterate name=autoForm property=menuEntries id=menuEntries tr td valign=middle bean:write name=menuEntries property=key/ html:hidden name=menuEntries property=key/ /td td valign=middle html:text name=menuEntries property=description size=15 maxlength=15/ /td td valign=top html:select name=menuEntries property=menuAction html:option value=Select A Action/html:option html:options name=actionNames labelName=actionNames/ /html:select /td I have 11 rows to iterate. for each html:select i have to invoke onchange method such that depending on the selection(for example if have options a,b,c,d in dropdownlist, i have to display a textfield called phonenumber only for options a,c.). My problem is i have to send some parameter in the onchange method, but since it is iteration every iteration has same propertyname, I have menuAction as property name for htmlselect. I should be able to get the phonenumber only for the options i sent when i load the page.(Iike edit page) I would appreciate if anyone can help me. Thanks, Latha __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Struts html:checkbox
Hi, Sorry if this problem has already been solved, I cannot seem to find anything in the Struts List Archive... I have an Action class that sets, in the ActionForward method of the said Action class, an attribute of an object in the request scope to push it to the presentation layer (JSP). In the JSP form, I use exclusively Custom Struts Tag to display data from the object in the request scope. Everything works greatly except for that html:checkbox property=propName value=${boolValue}/html:checkbox which doesn't seem to render the checked=checked attribute. The value of the value attribute is set to true... but for some reason, I can't seem to get it render checked on load. Is there a way to get a html:checkbox render as checked upon JSP load? Best regards, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple input forms - one action - one validator, how?
Hi Can! actually, i can't think of any other 'standard' solution (using the actionValidator you still would need the single input attribute) Maybe you could use a combined change of ActionMapping and ValidatorActionForm. Subclass those and set them in your config files. Change the ActionMapping so that getInputForward returns the forward you want. In validation of the form set this to what you want it to be. Let me know if it works ;) hth, axel On 2004-11-05 at 12:10:01 +0100, Can Gencer wrote: Hello, I have multiple forms that point to the same action. It is not a multipage form, it is done as different types of searches done on different pages) and I would like to validate the forms individually using the validate() method on the form bean. However, I am required to define an input= parameter for the action for the validation, and since the input pages can be different. I can solve this problem by having a different action name for each search page and make them point to the same action class, but is there a nicer solution for this? Thanks, Can - 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: Struts html:checkbox
Set the corresponding form property to true prior to loading the page. If the actual form property value equals the ${boolValue}, then the checkbox should render as checked. That is, it should produce the appropriate HTML which should render the checkbox as checked. robert -Original Message- From: Jean-Philippe Couture [mailto:[EMAIL PROTECTED] Sent: Friday, November 05, 2004 11:56 AM To: [EMAIL PROTECTED] Subject: Struts html:checkbox Hi, Sorry if this problem has already been solved, I cannot seem to find anything in the Struts List Archive... I have an Action class that sets, in the ActionForward method of the said Action class, an attribute of an object in the request scope to push it to the presentation layer (JSP). In the JSP form, I use exclusively Custom Struts Tag to display data from the object in the request scope. Everything works greatly except for that html:checkbox property=propName value=${boolValue}/html:checkbox which doesn't seem to render the checked=checked attribute. The value of the value attribute is set to true... but for some reason, I can't seem to get it render checked on load. Is there a way to get a html:checkbox render as checked upon JSP load? Best regards, - 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: Hi
Using indexed=true will generate names such as menuAction[0], menuAction[1] etc... html:select name=menuEntries property=menuAction indexed=true Niall - Original Message - From: Srilatha Salla [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 05, 2004 4:41 PM Subject: Hi Hi, I have a logic:iterate tag in my jsp. logic:iterate name=autoForm property=menuEntries id=menuEntries tr td valign=middle bean:write name=menuEntries property=key/ html:hidden name=menuEntries property=key/ /td td valign=middle html:text name=menuEntries property=description size=15 maxlength=15/ /td td valign=top html:select name=menuEntries property=menuAction html:option value=Select A Action/html:option html:options name=actionNames labelName=actionNames/ /html:select /td I have 11 rows to iterate. for each html:select i have to invoke onchange method such that depending on the selection(for example if have options a,b,c,d in dropdownlist, i have to display a textfield called phonenumber only for options a,c.). My problem is i have to send some parameter in the onchange method, but since it is iteration every iteration has same propertyname, I have menuAction as property name for htmlselect. I should be able to get the phonenumber only for the options i sent when i load the page.(Iike edit page) I would appreciate if anyone can help me. Thanks, Latha __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hi
Thanks for the help. I tried to understand what was on the site, it might take some time. If possible can you let me know how to implement it in my case. I have MenuEntry[] menuentries. in my form. MenuEntries has properties key, description and menuaction. So, what should i change this to. Thanks. Niall Pemberton [EMAIL PROTECTED] wrote: No you don't need 11 different methods, if you read through this it (hopefully) should be clearer http://struts.apache.org/faqs/indexedprops.html Niall - Original Message - From: Srilatha Salla To: Struts Users Mailing List Sent: Friday, November 05, 2004 5:49 PM Subject: Re: Hi Hi, i tried using indexed=true for id=menuEntries indexed=true/ size=15 maxlength=15 indexed=true/ indexed=true Select A Action labelName=actionNames/ maxlength=15/ I have a menuentry[] menuEntries property in formbean. so i need to index for description and key also. There is indexed attribute for html:text but not for bean:write So i used html:hidden indexed=true I have get and set methods in menuEntry class for key, description and menuaction. MenuEntry[] menuEntries = form.getMenuEntries(); in action class. tried retrieving the menuEntries[] in the action class. I get java.lang.NullPointerException at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils. java:515) so if I use indexed, should there be 11 different get and set methods because name of the property changes name=menuEntries[5].menuAction. Is there anyother way without using indexed, but send index of the property to the onchange method. Thanks, Latha. Niall Pemberton wrote: Using indexed=true will generate names such as menuAction[0], menuAction[1] etc... indexed=true Niall - Original Message - From: Srilatha Salla To: Sent: Friday, November 05, 2004 4:41 PM Subject: Hi Hi, I have a logic:iterate tag in my jsp. size=15 maxlength=15/ Select A Action labelName=actionNames/ I have 11 rows to iterate. for each html:select i have to invoke onchange method such that depending on the selection(for example if have options a,b,c,d in dropdownlist, i have to display a textfield called phonenumber only for options a,c.). My problem is i have to send some parameter in the onchange method, but since it is iteration every iteration has same propertyname, I have menuAction as property name for htmlselect. I should be able to get the phonenumber only for the options i sent when i load the page.(Iike edit page) I would appreciate if anyone can help me. Thanks, Latha __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com/a - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Authentication and Authorization
Hi Every One, Does Struts have any type of authentication/ authorization mecanism? Best regards, Davi Salgueiro
Authentication and Authorization
Hi Every One, Does Struts have any type of authentication/ authorization mecanism? Best regards, Davi Salgueiro
Re: Authentication and Authorization
Struts requires Servlet support container. Therefore containers (such as tomcat, resin, etc). support declerative security via web.xml. You can read for example about tomcat jdbc realms. So struts leverages J2EE security and you can extend it and customize it. .V Davi Salgueiro wrote: Hi Every One, Does Struts have any type of authentication/ authorization mecanism? Best regards, Davi Salgueiro - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Authentication and Authorization
El vie, 05-11-2004 a las 13:37 -0600, Vic (Vinny) Cekvenich escribió: Struts requires Servlet support container. Therefore containers (such as tomcat, resin, etc). support declerative security via web.xml. You can read for example about tomcat jdbc realms. So struts leverages J2EE security and you can extend it and customize it. .V In addition, if you work with JBOSS container then you can review: JBOSSSX library for security + JAAS. Regards. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Authentication and Authorization
Once you have your users and roles defined, you can read use the roles attribute for action mappings to restrict access to those actions to a set of roles. Hubert On Fri, 05 Nov 2004 16:46:51 -0300, Mauro Morales M. [EMAIL PROTECTED] wrote: El vie, 05-11-2004 a las 13:37 -0600, Vic (Vinny) Cekvenich escribió: Struts requires Servlet support container. Therefore containers (such as tomcat, resin, etc). support declerative security via web.xml. You can read for example about tomcat jdbc realms. So struts leverages J2EE security and you can extend it and customize it. .V In addition, if you work with JBOSS container then you can review: JBOSSSX library for security + JAAS. Regards. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue
I use tiles for it. A typical set of related definitions in my tiles configuration file: definition name=page.site.home path=/WEB-INF/jsp/layout/main.jsp put name=menu value=action.site.menu / put name=calendar value=action.site.calendar / put name=survey value=action.site.survey / put name=greeting value=tile.site.greeting / put name=main value=tile.site.home / /definition definition name=action.site.menu path=/menu.do/ definition name=action.site.calendar path=/calendar.do/ definition name=action.site.survey path=/survey.do/ definition name=tile.site.greeting path=/WEB-INF/jsp/tile/site/greeting.jsp/ definition name=tile.site.home path=/WEB-INF/jsp/tile/site/home.jsp/ In the main.jsp file I use tiles:insert for menu, calendar, survey, greeting and main Thompson Parke Jeff wrote: I'm still having trouble including a Struts action into a JSP (c:import url=/someAction.do /). I've tried using absolute URLs, passing the jsessionid to ensure that the session is not lost, but the request context is different between the JSP and the included action, so this not suitable for many situations. I've also tried upgrading to Struts 1.2.4. This does not resolve the Response has already been committed issue when including more than one Struts action in a JSP. The app server is using JRE 1.4.1_03-b02. Can anyone tell me whether they have seen this situation before? How common is it? Is it unusual to include Struts actions in JSPs? Anyone? Thanks, Jeff -Original Message- From: Parke Jeff Sent: Tuesday, November 02, 2004 3:23 PM To: [EMAIL PROTECTED] Subject: [] Including a Struts action in a JSP - IllegalStateException / truncated response issue Hello, I've seen a few posts on this subject, through this and other resources, but I haven't seen any appealing workarounds. I'd like to try to bring all the relevant information from these posts together and then ask for help in identifying a viable workaround. I apologize in advance if this issue is well known and understood and I just missed the best resources on the subject. Goals: 1) To build a Struts application where _every_ request to the application goes through a Struts action that collects and packages data then forwards (using Struts ActionForward's) to a JSP. 2) To be able to include one or more Struts actions in any given JSP (ie: c:import url=/someAction.do /). Behavior when implementing these goals: 1) Usually, when executing a single include of a Struts action on a JSP, everything works fine though sometimes there are problems (as listed below). 2) When including more than one Struts action on a JSP I get an IllegalStateException - Response has already been committed. 3) Sometimes, when a JSP only includes one Struts action, the first x bytes of the response will be missing when it is returned (without exception) to the client. Relevant issues (correct me where I'm wrong): 1) Including (jsp:include, c:import, etc.) a JSP/Servlet on a JSP sometimes (always?) causes the response to be committed because includes use RequestDispatcher.include() which in turn commits the response. 2) Forwarding a request using an ActionForward from a Struts action to a JSP can not be done when a response has been committed. 3) Increasing the response buffer size has no effect on these issues. 4) Using the include directive (%@ include file=filename %) won't work because that includes source a translation time. 5) It has been reported that using tiles:insert does not (fully/always?) resolve the problematic behavior. 6) Using absolute URLs with c:import prevents the response from being committed because the context of the request is assumed to be independent. The visibility of an authenticated, populated session can be affected by passing the jsessionid in on the URL. This seems to be the only viable workaround though I haven't tested it thoroughly yet. Reference: http://www.mail-archive.com/[EMAIL PROTECTED]/msg13284.html http://www.jguru.com/faq/view.jsp?EID=501393 http://www.mail-archive.com/[EMAIL PROTECTED]/msg05711.htm l http://www.mail-archive.com/[EMAIL PROTECTED]/msg15194.html http://forum.java.sun.com/thread.jsp?thread=484731forum=45message=2266 277 http://www.mail-archive.com/[EMAIL PROTECTED]/msg15189.html http://jguru.com/forums/view.jsp?EID=1204797 http://forum.java.sun.com/thread.jsp?thread=461644forum=45message=2115 900 http://www.mail-archive.com/[EMAIL PROTECTED]/msg18018.html http://www.mail-archive.com/[EMAIL PROTECTED]/msg74816.html http://www.mail-archive.com/[EMAIL PROTECTED]/msg29073.html My setup: - Oracle AS 10g (OC4J) app server - Struts 1.1 - JSTL 1.0.6 Is there any clean way to meet the two goals listed above without error? Thanks, Jeff - To unsubscribe, e-mail: [EMAIL PROTECTED] For
Re: Using Forward and Include using RequestProcessor
posting again On Fri, 5 Nov 2004 10:49:25 -0800, Sanjay Choudhary [EMAIL PROTECTED] wrote: Hi All, I have an application which contains 100+ jsp's. Use case is to inject the Javascript conditionally into the JSP's. Condition is - If a cookie is present in the request, inject the Javascript else leave it alone. I started with a simple struts example project for the proof of concept. I thought of a Servlet Filter and I created a filter as below import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; public class SecurePageFilter implements Filter { private static final String SECURITY_COOKIE = ObSSOCookie; private static final String SECURITY_JS = /check.js; public void init(FilterConfig filterConfig) throws ServletException { } public void destroy() { } public void doFilter( ServletRequest oRequest, ServletResponse oResponse, FilterChain oFilterChain) throws IOException, ServletException { oFilterChain.doFilter(oRequest, oResponse); HttpServletRequest woRequest = (HttpServletRequest) oRequest; Cookie[] aoCookies = woRequest.getCookies(); String strUrl = woRequest.getRequestURI(); if (strUrl != null strUrl.endsWith(deleteCookie.jsp) || aoCookies == null) return; for (int i = 0; i aoCookies.length; i++) { Cookie oCookie = aoCookies[i]; if (oCookie.getName().equals(SECURITY_COOKIE)) { String strValue = oCookie.getValue(); if (strValue != null strValue.length() 0) { RequestDispatcher rd = woRequest.getRequestDispatcher(SECURITY_JS); rd.include(oRequest, oResponse); oResponse.flushBuffer(); return; } } } return; } // doFilter } // SecurePageFilter My filter is mapped to (*.jsp and *.do) in the web.xml. This works fine if I have a URI as http://localhost:9080/struts-example/welcome.jsp But this doesn't work if I use the URL http://localhost:9080/struts-example/welcome.do To explore more I downloaded Struts 1.2 source and took a look in RequestDispatcher class -- processForward(..) , processInclude(..), doForward(..) and doInclude(..) methods. And off course, process(..) method. In the process method , if request is forwarded using the RequestDispatcher, which is normally the case in *.do types URI's, control is returned back to the servlet without processing the 'processInclude'. I further extended the RequestDispatcher class and implemented my own doForward method. This is more or less same as Struts implementation but also calls includes. Code is as below :- protected void doForward( String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Unwrap the multipart request, if there is one. if (request instanceof MultipartRequestWrapper) { request = ((MultipartRequestWrapper) request).getRequest(); } RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd == null) { response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getInternal().getMessage(requestDispatcher, uri)); return; } rd.forward(request, response); doIncludeJS(request,response); } protected void doIncludeJS( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Cookie[] aoCookies = request.getCookies(); String strUrl = request.getRequestURI(); if (strUrl != null strUrl.endsWith(deleteCookie.jsp) || aoCookies == null) return; for (int i = 0; i aoCookies.length; i++) { Cookie oCookie = aoCookies[i]; if (oCookie.getName().equals(SECURITY_COOKIE)) { String strValue = oCookie.getValue(); if (strValue != null strValue.length() 0) { doInclude(SECURITY_JS,request, response); break; } } } return; } Still to my surprise, JS file did not get injected in the response.( I debugged the application do ensure that doInclude(..) method is called) [Q1] - Can we use RequestDispatcher to Forward and Include for the same request/response? (I know we can't do Include and Forward, it throws an
Fwd: Using Forward and Include using RequestProcessor
-- Forwarded message -- From: Sanjay Choudhary [EMAIL PROTECTED] Date: Fri, 5 Nov 2004 10:49:25 -0800 Subject: Using Forward and Include using RequestProcessor To: [EMAIL PROTECTED] Hi All, I have an application which contains 100+ jsp's. Use case is to inject the Javascript conditionally into the JSP's. Condition is - If a cookie is present in the request, inject the Javascript else leave it alone. I started with a simple struts example project for the proof of concept. I thought of a Servlet Filter and I created a filter as below import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; public class SecurePageFilter implements Filter { private static final String SECURITY_COOKIE = ObSSOCookie; private static final String SECURITY_JS = /check.js; public void init(FilterConfig filterConfig) throws ServletException { } public void destroy() { } public void doFilter( ServletRequest oRequest, ServletResponse oResponse, FilterChain oFilterChain) throws IOException, ServletException { oFilterChain.doFilter(oRequest, oResponse); HttpServletRequest woRequest = (HttpServletRequest) oRequest; Cookie[] aoCookies = woRequest.getCookies(); String strUrl = woRequest.getRequestURI(); if (strUrl != null strUrl.endsWith(deleteCookie.jsp) || aoCookies == null) return; for (int i = 0; i aoCookies.length; i++) { Cookie oCookie = aoCookies[i]; if (oCookie.getName().equals(SECURITY_COOKIE)) { String strValue = oCookie.getValue(); if (strValue != null strValue.length() 0) { RequestDispatcher rd = woRequest.getRequestDispatcher(SECURITY_JS); rd.include(oRequest, oResponse); oResponse.flushBuffer(); return; } } } return; } // doFilter } // SecurePageFilter My filter is mapped to (*.jsp and *.do) in the web.xml. This works fine if I have a URI as http://localhost:9080/struts-example/welcome.jsp But this doesn't work if I use the URL http://localhost:9080/struts-example/welcome.do To explore more I downloaded Struts 1.2 source and took a look in RequestDispatcher class -- processForward(..) , processInclude(..), doForward(..) and doInclude(..) methods. And off course, process(..) method. In the process method , if request is forwarded using the RequestDispatcher, which is normally the case in *.do types URI's, control is returned back to the servlet without processing the 'processInclude'. I further extended the RequestDispatcher class and implemented my own doForward method. This is more or less same as Struts implementation but also calls includes. Code is as below :- protected void doForward( String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Unwrap the multipart request, if there is one. if (request instanceof MultipartRequestWrapper) { request = ((MultipartRequestWrapper) request).getRequest(); } RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd == null) { response.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, getInternal().getMessage(requestDispatcher, uri)); return; } rd.forward(request, response); doIncludeJS(request,response); } protected void doIncludeJS( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Cookie[] aoCookies = request.getCookies(); String strUrl = request.getRequestURI(); if (strUrl != null strUrl.endsWith(deleteCookie.jsp) || aoCookies == null) return; for (int i = 0; i aoCookies.length; i++) { Cookie oCookie = aoCookies[i]; if (oCookie.getName().equals(SECURITY_COOKIE)) { String strValue = oCookie.getValue(); if (strValue != null strValue.length() 0) { doInclude(SECURITY_JS,request, response); break; } } } return; } Still to my surprise, JS file did not get injected in the response.( I debugged the application do ensure that doInclude(..) method is called) [Q1] - Can we use RequestDispatcher to Forward and Include for the same request/response? (I know we can't do Include and Forward, it throws an error. But in case of Forward and
RE: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue
Jeff, Try this previous post on IllegalStateException response has already been committed: http://marc.theaimsgroup.com/?l=struts-userm=108152145227595w=2 The author suggested 2 courses of action: 1. Try increasing the buffer size on myjsp.jsp. Default is 8kb 2. Make sure that you are not changing the header portion of the response in your included JSP page. I remember a post with the same exception and the issue was a buffer issue. Regards, David -Original Message- From: Parke Jeff [mailto:[EMAIL PROTECTED] Sent: Friday, November 05, 2004 11:28 AM To: [EMAIL PROTECTED] Cc: Struts Users Mailing List Subject: Re: [] Including a Struts action in a JSP - IllegalStateException / truncated response issue Thanks for the information, Jeff. Unfortunately, though the Tiles Advanced Features Guide indicates it is possible to include multiple Struts actions (using tiles:insert) on one page, I _still_ get the IllegalStateException Response has already been committed. We often need to prepare data to be shown by a JSP page. In the MVC framework, the controller prepares data (in the model) to be shown by the view. Translated to Tiles and Struts, we can use a Struts Action as a controller, a JSP page as a view, and combine both in a Tile. So, when you insert the Tile, the Action is called before the JSP page is displayed. Now, your complex web page can be made of Tiles fed by controllers (one sub-controller for each Tile). This approach is better than one single controller for all Tiles of the page, because it really allows building autonomous Tiles, without worrying about how to fed (sic) them all. - Tiles Advanced Features Guide (http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf) This is describing exactly what I want to accomplish and the reason for it but I keep running into the same committed response problem. Is it possible that this is a container issue rather than being a Struts issue? Can someone else confirm that c:import and tiles:insert both cause an IllegalStateException when including more than 1 (actually try 3 or 4) Struts action on the same JSP? Thanks again for anyone who can help, Jeff I think that it is unusual to directly include Struts actions in JSP files. When composing pages of different parts, Tiles is the much more common approach. The standard usage of Tiles is to include JSP files directly, but you can use tiles to include Struts actions in JSP files. (See Section 5.2 of the Tiles Advanced Features guide, a PDF file, at http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf.) -- Jeff Parke Jeff wrote: I'm still having trouble including a Struts action into a JSP (c:import url=/someAction.do /). I've tried using absolute URLs, passing the jsessionid to ensure that the session is not lost, but the request context is different between the JSP and the included action, so this not suitable for many situations. I've also tried upgrading to Struts 1.2.4. This does not resolve the Response has already been committed issue when including more than one Struts action in a JSP. The app server is using JRE 1.4.1_03-b02. Can anyone tell me whether they have seen this situation before? How common is it? Is it unusual to include Struts actions in JSPs? Anyone? Thanks, Jeff - 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: Hi
Hi, I am able to display the text field for phoneNumber now. The code i wrote is logic:iterate name=autoForm property=menuEntries id=menuEntries indexId=idx tr td valign=middle bean:write name=menuEntries property=key/ html:hidden name=menuEntries property=key/ /td td valign=middle html:text name=menuEntries property=description size=15 maxlength=15/ /td td valign=top html:select name=menuEntries property=menuAction onchange='%=showOrHidePhoneNumber(this.value, +idx+);%' html:option value=Select A Action/html:option html:options name=actionNames labelName=actionNames/ /html:select /td td div id=%=idx% style={display:inline} html:text property=phoneNumber size=15 maxlength=15/ /div /td !-- /tr -- /logic:iterate function showOrHidePhoneNumber(actionselected,index) { alert(index); alert(actionselected); if(actionselected==Transfer with prompt) { document.getElementById(index).style.display = inline; } else { document.getElementById(index).style.display = none; } } I have to call showOrHidePhoneNumber(actionselected,index) when the page loads. And it should not display the textfield for phoneNumber for all 11rows as the default option is not Transfer with prompt. Help me figure out this function. Thanks, Latha Srilatha Salla [EMAIL PROTECTED] wrote: Thanks for the help. I tried to understand what was on the site, it might take some time. If possible can you let me know how to implement it in my case. I have MenuEntry[] menuentries. in my form. MenuEntries has properties key, description and menuaction. So, what should i change this to. Thanks. Niall Pemberton wrote: No you don't need 11 different methods, if you read through this it (hopefully) should be clearer http://struts.apache.org/faqs/indexedprops.html Niall - Original Message - From: Srilatha Salla To: Struts Users Mailing List Sent: Friday, November 05, 2004 5:49 PM Subject: Re: Hi Hi, i tried using indexed=true for id=menuEntries indexed=true/ size=15 maxlength=15 indexed=true/ indexed=true Select A Action labelName=actionNames/ maxlength=15/ I have a menuentry[] menuEntries property in formbean. so i need to index for description and key also. There is indexed attribute for html:text but not for bean:write So i used html:hidden indexed=true I have get and set methods in menuEntry class for key, description and menuaction. MenuEntry[] menuEntries = form.getMenuEntries(); in action class. tried retrieving the menuEntries[] in the action class. I get java.lang.NullPointerException at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils. java:515) so if I use indexed, should there be 11 different get and set methods because name of the property changes name=menuEntries[5].menuAction. Is there anyother way without using indexed, but send index of the property to the onchange method. Thanks, Latha. Niall Pemberton wrote: Using indexed=true will generate names such as menuAction[0], menuAction[1] etc... indexed=true Niall - Original Message - From: Srilatha Salla To: Sent: Friday, November 05, 2004 4:41 PM Subject: Hi Hi, I have a logic:iterate tag in my jsp. size=15 maxlength=15/ Select A Action labelName=actionNames/ I have 11 rows to iterate. for each html:select i have to invoke onchange method such that depending on the selection(for example if have options a,b,c,d in dropdownlist, i have to display a textfield called phonenumber only for options a,c.). My problem is i have to send some parameter in the onchange method, but since it is iteration every iteration has same propertyname, I have menuAction as property name for htmlselect. I should be able to get the phonenumber only for the options i sent when i load the page.(Iike edit page) I would appreciate if anyone can help me. Thanks, Latha __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com/a - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired
struts tiles tab and border
For page or summary tab, a tab is label of words. Can I change it to an image file? If not, can I add an image file? Moreover, there is a purple border after clicking a tab. Can I change the border color and even remove it? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problem with tiles
Hi Every body, I developed a page using tiles and used struts-html tags in template page. As a result when main page is excuted struts-html tags in template page are not rendered. How to get Struts-html tags rendred when calling template page in main page? Amit Gupta
Re: Authentication and Authorization
There used to be (haven't checked on it for a while) a project called Security Filter that was a security database implementation you could package with your application. I believe it was a SourceForge project. One of the projects I'm currently architecting has need for specialized security - above and beyond what our CMS will do (CMS will handle it to the application on a per-user bases). I'm implementing this through use of a Filter and a HTTPRequestWrapper. Oh, and I've tossed in a custom implementation of Principal to make things nice and tidy. Once complete I'll be able to leverage standard calls like isUserInRole and getUserPrincipal to deal with my users. The nice thing is, because of the nature of filters, once I'm done with this I can jar it up, drop it in any application I write (and add to the web.xml of that app) and use the exact same thing for many other applications (I have at least 2 to get out this quarter ... they seem to be finding new ones for me to write all the time)! Gotta love real reuse in actual practice! ;-) Filters fit a lot of problems really nicely - even if you don't build a request/response wrapper to go along with them. They're extremely handy for the problems that they do solve. Good Luck, Eddie - Original Message - From: Davi Salgueiro [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 05, 2004 1:30 PM Subject: Authentication and Authorization Hi Every One, Does Struts have any type of authentication/ authorization mecanism? Best regards, Davi Salgueiro --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0445-2, 11/04/2004 Tested on: 11/6/2004 12:48:22 AM avast! - copyright (c) 2000-2004 ALWIL Software. http://www.avast.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Authentication and Authorization
There used to be (haven't checked on it for a while) a project called Security Filter that was a security database implementation you could package with your application. I believe it was a SourceForge project. SecurityFilter hasn't been updated since January: http://securityfilter.sourceforge.net/ Pow2ACL is older, hasn't been updated in 2 years, but has groups and roles, not just one role: http://sourceforge.net/projects/pow2acl/ It also has Struts compatible classes including ActionServlet, ActionMapping, RoleAction and a DispatcherAction. Then there is always the good old JAAS. Regards, David - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with tiles
Amit, What do you mean by main page? Your web.xml's welcome-file-list such as index.jsp? If so, I posted about it within the last 24 hours. Try something like this in your index.jsp file: %@ taglib uri=/WEB-INF/tiles.tld prefix=tiles % tiles:insert definition=someDefinition/ Regards, David -Original Message- From: Amit Gupta [mailto:[EMAIL PROTECTED] Sent: Saturday, November 06, 2004 12:55 AM To: Struts Users Mailing List Subject: problem with tiles Hi Every body, I developed a page using tiles and used struts-html tags in template page. As a result when main page is excuted struts-html tags in template page are not rendered. How to get Struts-html tags rendred when calling template page in main page? Amit Gupta - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]