Re: Tile Problem
I followed your suggestion. Now, when I ran my application, I got article.Main.title???en_US.??? displayed in the browser. Still, cannot pick up the article.Menu.title=Registered Members in the application.properties (which is located in the ApplicationRoot/WEB-INF/classes/resources folder). Here is my code: [CODE] . %@ taglib uri=/WEB-INF/lib/struts-bean-el.tld prefix=bean-el % html:html HEAD html:base/ TITLE./TITLE /HEAD BODY c:set var=titleKeytiles:getAsString name=title//c:setbean-el:message key=${titleKey}/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/CODE] In my tiles-def.xml, I have: [CODE] definition name=.article.Menu extends=.article.Base put name=title value=article.Menu.title/ put name=content value=/article/content/menu.jsp/ put name=navbar value=/article/common/navbarMenu.jsp/ /definition [/CODE] -Caroline --- Jason Lea [EMAIL PROTECTED] wrote: Are you using the struts-el tags. You might have them installed as bean-el in which case you would need to use c:set var=titleKeytiles:getAsString name=title//c:setbean-el:message key=${titleKey}/ I only use the EL tags, so I just use bean as the tag prefix eg %@ taglib uri=/WEB-INF/jsp/tags/struts-bean-el.tld prefix=bean % Caroline Jen wrote: I tried both of your suggestions. For example, I have [code] . BODY c:set var=titleKeytiles:getAsString name=title//c:setbean:message key=${titleKey}/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/code] I got java.lang.IllegalArgumentException: can't parse argument number titleKey --- Jason Lea [EMAIL PROTECTED] wrote: If you are using JSTL you can do this: tile:useAttribute id=titleKey name=titlebean:message key=${titleKey}/ if that doesn't work, try this: c:set var=titleKeytiles:getAsString name=title//c:setbean:message key=${titleKey}/ Caroline Jen wrote: In general, the tile works fine for me except the title piece. [CODE] . BODY tiles:getAsString name=title/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/CODE] In my tiles-def.xml, I have: [CODE] definition name=.article.Menu extends=.article.Base put name=title value=article.Menu.title/ put name=content value=/article/content/menu.jsp/ put name=navbar value=/article/common/navbarMenu.jsp/ /definition [/CODE] The problem is that my application displays article.Menu.title in the browser, instead of going to the application.properties (which is in the ApplicationRoot/WEB-INF/classes/resources folder) to get article.Menu.title=Registered Members What should I do? __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tile Problem
Huraah!! tiles:useAttribute name=title/ bean:message name=title/ worked. I have been carrying this problem with me for quite some time. Finally got it. --- Avinash Gangadharan [EMAIL PROTECTED] wrote: Try the code below. This should work. [CODE] . %@ taglib uri=/WEB-INF/lib/struts-bean.tld prefix=bean % html:html HEAD html:base/ TITLE./TITLE /HEAD BODY tiles:useAttribute name=title/ bean:message name=title/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/CODE] -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Thursday, March 25, 2004 4:52 PM To: Struts Users Mailing List Subject: Re: Tile Problem I followed your suggestion. Now, when I ran my application, I got article.Main.title???en_US.??? displayed in the browser. Still, cannot pick up the article.Menu.title=Registered Members in the application.properties (which is located in the ApplicationRoot/WEB-INF/classes/resources folder). Here is my code: [CODE] . %@ taglib uri=/WEB-INF/lib/struts-bean-el.tld prefix=bean-el % html:html HEAD html:base/ TITLE./TITLE /HEAD BODY c:set var=titleKeytiles:getAsString name=title//c:setbean-el:message key=${titleKey}/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/CODE] In my tiles-def.xml, I have: [CODE] definition name=.article.Menu extends=.article.Base put name=title value=article.Menu.title/ put name=content value=/article/content/menu.jsp/ put name=navbar value=/article/common/navbarMenu.jsp/ /definition [/CODE] -Caroline --- Jason Lea [EMAIL PROTECTED] wrote: Are you using the struts-el tags. You might have them installed as bean-el in which case you would need to use c:set var=titleKeytiles:getAsString name=title//c:setbean-el:message key=${titleKey}/ I only use the EL tags, so I just use bean as the tag prefix eg %@ taglib uri=/WEB-INF/jsp/tags/struts-bean-el.tld prefix=bean % Caroline Jen wrote: I tried both of your suggestions. For example, I have [code] . BODY c:set var=titleKeytiles:getAsString name=title//c:setbean:message key=${titleKey}/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/code] I got java.lang.IllegalArgumentException: can't parse argument number titleKey --- Jason Lea [EMAIL PROTECTED] wrote: If you are using JSTL you can do this: tile:useAttribute id=titleKey name=titlebean:message key=${titleKey}/ if that doesn't work, try this: c:set var=titleKeytiles:getAsString name=title//c:setbean:message key=${titleKey}/ Caroline Jen wrote: In general, the tile works fine for me except the title piece. [CODE] . BODY tiles:getAsString name=title/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/CODE] In my tiles-def.xml, I have: [CODE] definition name=.article.Menu extends=.article.Base put name=title value=article.Menu.title/ put name=content value=/article/content/menu.jsp/ put name=navbar value=/article/common/navbarMenu.jsp/ /definition [/CODE] The problem is that my application displays article.Menu.title in the browser, instead of going to the application.properties (which is in the ApplicationRoot/WEB-INF/classes/resources folder) to get article.Menu.title=Registered Members What should I do? __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html === message truncated === __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tile Problem
In general, the tile works fine for me except the title piece. [CODE] . BODY tiles:getAsString name=title/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/CODE] In my tiles-def.xml, I have: [CODE] definition name=.article.Menu extends=.article.Base put name=title value=article.Menu.title/ put name=content value=/article/content/menu.jsp/ put name=navbar value=/article/common/navbarMenu.jsp/ /definition [/CODE] The problem is that my application displays article.Menu.title in the browser, instead of going to the application.properties (which is in the ApplicationRoot/WEB-INF/classes/resources folder) to get article.Menu.title=Registered Members What should I do? __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tile Problem
I tried both of your suggestions. For example, I have [code] . BODY c:set var=titleKeytiles:getAsString name=title//c:setbean:message key=${titleKey}/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/code] I got java.lang.IllegalArgumentException: can't parse argument number titleKey --- Jason Lea [EMAIL PROTECTED] wrote: If you are using JSTL you can do this: tile:useAttribute id=titleKey name=titlebean:message key=${titleKey}/ if that doesn't work, try this: c:set var=titleKeytiles:getAsString name=title//c:setbean:message key=${titleKey}/ Caroline Jen wrote: In general, the tile works fine for me except the title piece. [CODE] . BODY tiles:getAsString name=title/ tiles:get name=header/ tiles:get name=message/ tiles:get name=content/ tiles:get name=navbar/ /BODY . [/CODE] In my tiles-def.xml, I have: [CODE] definition name=.article.Menu extends=.article.Base put name=title value=article.Menu.title/ put name=content value=/article/content/menu.jsp/ put name=navbar value=/article/common/navbarMenu.jsp/ /definition [/CODE] The problem is that my application displays article.Menu.title in the browser, instead of going to the application.properties (which is in the ApplicationRoot/WEB-INF/classes/resources folder) to get article.Menu.title=Registered Members What should I do? __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Retrieve a Variable From the DynaActionForm
In my Struts application, postForm is of the DynaActionForm type: DynaActionForm postForm = ( DynaActionForm )form; Later on, I want to save one of the fields receiver, which is a String, in the request context. Which is the following is the correct syntax? request.setAttribute( Receiver, postForm.get( receiver) ); Or request.setAttribute( Receiver, ( String )postForm.get( receiver) ); __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Which Directory Does the Configuration File Go?
I have code like: private static final String OPTION_FILE_NAME = mvnplugin_mvnforum_MVNForumConfig; static { ResourceBundle res = ResourceBundle.getBundle(OPTION_FILE_NAME); MVNFORUM_HOME = res.getString(MVNFORUM_HOME).trim(); WEBMASTER_EMAIL = res.getString(WEBMASTER_EMAIL).trim(); LOGO_URL = res.getString(LOGO_URL).trim(); String supportedLocales = res.getString(SUPPORTED_LOCALES).trim(); SUPPORTED_LOCALE_NAMES = StringUtil.getStringArray(supportedLocales, ;); . . } And mvnplugin_mvnforum_MVNForumConfig.properties is a configuration file. Please advise regarding the directory in which this properties file is supposed to be for my code to read it properly. __ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Where Do I Put This properties File (internationalization)
I am using Struts and internationalization. I have code like: private static final String OPTION_FILE_NAME = mvnplugin_mvnforum_MVNForumConfig; static { ResourceBundle res = ResourceBundle.getBundle(OPTION_FILE_NAME); } And mvnplugin_mvnforum_MVNForumConfig is a properties file. Please advice regarding the directory in which this properties file is supposed to be. __ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Looking for junior Java/Struts developers
I would like to give a try. I live in Manassas, VA. Please find my resume in the Word format in the attachment. Caroline Jen Tel: 703-369-3257 --- Yibing Li [EMAIL PROTECTED] wrote: Folks, We are actively looking for java/struts/jboss developers here at GNX (www.gnx.com). If you have one year of experience using java/struts or jboss and are willing to relocate to Herndon, VA, please send me your resume to [EMAIL PROTECTED], The salary is around $50k. Thanks, Yibing - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm)
Robert, I followed your advices. Your code works very well. I have successfully inserted all the values of my bean properties into the database. Thank you very much. --- Robert Taylor [EMAIL PROTECTED] wrote: The same problem exists, you are calling getters on a ThreadBean instance which has not yet been populated. Below three ways to accomplish your goal: METHOD 1: Try this (proxy): public final class ThreadHandler { MessageDAO md = new MySQLMessageDAO(); public int insertThread(ThreadBean bean) throws throws MessageDAOSysException, ObjectNotFoundException { int identity = 0; md.createThread(bean.getReceiver(), bean.getSender(), bean.getThreadTopic(), bean.getThreadBody(), bean.getThreadCreationDate(), bean.getThreadViewCount(), bean.getThreadReplyCount()); // get identity return identity; } } ThreadBean bean = new ThreadBean(); BeanUtils.copyProperties(bean, postForm); ThreadHandler th = new ThreadHandler() th.insertThread(bean); If you do it this way, then it would be better if ThreadHandler was a singleton, but that's a different discussion :) METHOD 2: Another way to do it (design by composition). public final class ThreadHandler { MessageDAO md = new MySQLMessageDAO(); ThreadBean bean; public ThreadHandler(ThreadBean bean) { this.bean = bean; } public int insertThread() throws throws MessageDAOSysException, ObjectNotFoundException { int identity = 0; md.createThread(bean.getReceiver(), bean.getSender(), bean.getThreadTopic(), bean.getThreadBody(), bean.getThreadCreationDate(), bean.getThreadViewCount(), bean.getThreadReplyCount()); // get identity return identity; } } ThreadBean bean = new ThreadBean(); BeanUtils.copyProperties(bean, postForm); ThreadHandler th = new ThreadHandler(bean) th.insertThread(); METHOD 3: Yet another way via classic inheritance: public final class ThreadHandler extends ThreadBean { MessageDAO md = new MySQLMessageDAO(); public ThreadHandler() { super(); } public int insertThread() throws throws MessageDAOSysException, ObjectNotFoundException { int identity = 0; md.createThread(this.getReceiver(), this.getSender(), this.getThreadTopic(), this.getThreadBody(), this.getThreadCreationDate(), this.getThreadViewCount(), this.getThreadReplyCount()); // get identity return identity; } } ThreadHandler th = new ThreadHandler(); BeanUtils.copyProperties(th, postForm); th.insertThread(); hth, robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Thursday, January 08, 2004 11:48 AM To: Struts Users Mailing List Subject: RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm) Thank you for your comment, which is very helpful. Instead of extends ThreadBean, I now import the ThreadBean into my ThreadHandler class (see the code below). I am still getting all null or zero values from the bean. What is the proper way to do it? I simply want to insert the value of all the properties into the database. Most of the fields in my database require NOT NULL. code: == import org.apache.artimus.message.ThreadBean; class ThreadHandler { ThreadBean threadBean = new ThreadBean(); String receiver = threadBean.getReceiver(); String sender = threadBean.getSender(); String threadTopic = threadBean.getPostTopic(); String threadBody = threadBean.getPostBody(); Timestamp threadCreationDate = threadBean.getThreadCreationDate(); int threadViewCount = threadBean.getThreadViewCount(); int threadReplyCount = threadBean.getThreadReplyCount(); MessageDAO md = new MySQLMessageDAO(); public int insertThread( ThreadBean threadBean ) throws MessageDAOSysException, ObjectNotFoundException { System.out.println( The sender is + sender + . ); System.out.println( The subject is + threadTopic + . ); System.out.println( The creation date is + threadCreationDate ); System.out.println( The number of replies are === message truncated === __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing
RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm)
Thank you for your comment, which is very helpful. Instead of extends ThreadBean, I now import the ThreadBean into my ThreadHandler class (see the code below). I am still getting all null or zero values from the bean. What is the proper way to do it? I simply want to insert the value of all the properties into the database. Most of the fields in my database require NOT NULL. code: == import org.apache.artimus.message.ThreadBean; class ThreadHandler { ThreadBean threadBean = new ThreadBean(); String receiver = threadBean.getReceiver(); String sender = threadBean.getSender(); String threadTopic = threadBean.getPostTopic(); String threadBody = threadBean.getPostBody(); Timestamp threadCreationDate = threadBean.getThreadCreationDate(); int threadViewCount = threadBean.getThreadViewCount(); int threadReplyCount = threadBean.getThreadReplyCount(); MessageDAO md = new MySQLMessageDAO(); public int insertThread( ThreadBean threadBean ) throws MessageDAOSysException, ObjectNotFoundException { System.out.println( The sender is + sender + . ); System.out.println( The subject is + threadTopic + . ); System.out.println( The creation date is + threadCreationDate ); System.out.println( The number of replies are + threadReplyCount ); md.createThread( receiver, sender, threadTopic, threadBody, threadCreationDate, threadViewCount, threadReplyCount ); int threadID = 0; . . return threadID; } } --- Robert Taylor [EMAIL PROTECTED] wrote: Your code seems a bit confusing based upon what you want to achieve. If indeed you want ThreadHandler to inherit from ThreadBean, you should be able to do something like this: DynaActionForm postForm = ( DynaActionForm )form; ThreadHander = new ThreadHandler(); BeanUtils.copyProperties( threadHandler, postForm ); threadHandler.insertThread(); The reason you are getting null and zero values in ThreadHandler is that you are populating a new instance of ThreadBean here: DynaActionForm postForm = ( DynaActionForm )form; ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); ... and then you get a new instance of ThreadHandler here: ThreadHandler thandler = new ThreadHandler(); At this point, ThreadHandler knows nothing of your populated instance of ThreadBean. Instead it is getting values from its own empty ThreadBean parent here: class ThreadHandler extends ThreadBean { String receiver = getReceiver(); String sender = getSender(); String threadTopic = getPostTopic(); String threadBody = getPostBody(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); int threadReplyCount = getThreadReplyCount(); . . } ...unless you do something like the following in ThreadHandler.insertThread(): public int insertThread(ThreadBean bean) throws SomeException { this.receiver = bean.getReceiver(); this.sender = bean.getSender(); // insert code here } which from a design perspective, I'm not sure why you would want to do it this way. hth, robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 10:27 PM To: Struts Users Mailing List Subject: RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm) I have narrowed down the problem. Something went wrong in my business tier class (ThreadHandler.java). All the properties in the JavaBean are populated properly (I have checked). The way I coded in the ThreadHandler class failed to retrieve the value of all the properties in the JavaBean (ThreadBean.java). All the values turned out to be null or 0. Now, what is wrong with the code? class ThreadHandler extends ThreadBean { String receiver = getReceiver(); String sender = getSender(); String threadTopic = getPostTopic(); String threadBody = getPostBody(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); int threadReplyCount = getThreadReplyCount(); . . } To answer your question: 1. Have you checked to make sure that the fields you expect actually exist in the form before calling BeanUtils.copyProperties()? Yes, I have printed out the contents of the JSP text fields in my action class, which is a servlet. For example: System.out.println( the sender is + postForm.get( sender ) ); 2. If so, have you checked to see if the data was copied properly just after
RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm)
Robert, you are absolutely right. I am trying to build a personal message inbox using Struts. I use the word Thread to represent a discussion topic. My ThreadHandler is a business tier class. The word Thread has nothing to do with the java.lang.Thread. -Caroline --- Robert Taylor [EMAIL PROTECTED] wrote: I don't think ThreadHandler represents a java.lang.Thread handler. I think it more or less is a business object to facilitate persistance. I think the use of the word Thread here is more representative of a forum discussion thread. I could be wrong though. robert -Original Message- From: Yee, Richard K,,DMDCWEST [mailto:[EMAIL PROTECTED] Sent: Thursday, January 08, 2004 12:00 PM To: 'Struts Users Mailing List' Subject: RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm) Caroline, May I ask why you are performing your database updates through a separate thread? It seems to be complicating your code. Creating lots of threads from within your web application is not a good practice if you want your app to scale well. Also, what happens if the update doesn't succeed? You have no way of notifying the user. The code: snip ThreadBean threadBean = new ThreadBean(); String receiver = threadBean.getReceiver(); String sender = threadBean.getSender(); /snip is your problem unless your ThreadBean constructor can populate itself correctly with the desired values. If you must use threads, then you should be able to create a ThreadHandler, call a setter method on it and set you ThreadBean instance variable, and then call the run method on the ThreadHandler to start the thread. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Thursday, January 08, 2004 8:48 AM To: Struts Users Mailing List Subject: RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm) Thank you for your comment, which is very helpful. Instead of extends ThreadBean, I now import the ThreadBean into my ThreadHandler class (see the code below). I am still getting all null or zero values from the bean. What is the proper way to do it? I simply want to insert the value of all the properties into the database. Most of the fields in my database require NOT NULL. code: == import org.apache.artimus.message.ThreadBean; class ThreadHandler { ThreadBean threadBean = new ThreadBean(); String receiver = threadBean.getReceiver(); String sender = threadBean.getSender(); String threadTopic = threadBean.getPostTopic(); String threadBody = threadBean.getPostBody(); Timestamp threadCreationDate = threadBean.getThreadCreationDate(); int threadViewCount = threadBean.getThreadViewCount(); int threadReplyCount = threadBean.getThreadReplyCount(); MessageDAO md = new MySQLMessageDAO(); public int insertThread( ThreadBean threadBean ) throws MessageDAOSysException, ObjectNotFoundException { System.out.println( The sender is + sender + . ); System.out.println( The subject is + threadTopic + . ); System.out.println( The creation date is + threadCreationDate ); System.out.println( The number of replies are + threadReplyCount ); md.createThread( receiver, sender, threadTopic, threadBody, threadCreationDate, threadViewCount, threadReplyCount ); int threadID = 0; . . return threadID; } } --- Robert Taylor [EMAIL PROTECTED] wrote: Your code seems a bit confusing based upon what you want to achieve. If indeed you want ThreadHandler to inherit from ThreadBean, you should be able to do something like this: DynaActionForm postForm = ( DynaActionForm )form; ThreadHander = new ThreadHandler(); BeanUtils.copyProperties( threadHandler, postForm ); threadHandler.insertThread(); The reason you are getting null and zero values in ThreadHandler is that you are populating a new instance of ThreadBean here: DynaActionForm postForm = ( DynaActionForm )form; ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); ... and then you get a new instance of ThreadHandler here: ThreadHandler thandler = new ThreadHandler(); At this point, ThreadHandler knows nothing of your populated instance of ThreadBean. Instead it is getting values from its own empty ThreadBean parent here: class ThreadHandler extends ThreadBean { String receiver = getReceiver
All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm)
Hi, my program compiled OKay. When I ran the application, somehow, the properties of my DynaValidatorForm are not passed from the action class to the business tier and then to the data access tier. Please help me taking a look at what went wrong. It looks that the validation worked fine: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ . . /form-bean because when I intentionally left several of the text fields blank and submitted my JSP form, an applet got prompted showing something in those fields are required. In my action class (see below), I used BeanUtils to copy all the properties of the DynaValidatorForm to a bean (ThreadBean): DynaActionForm postForm = ( DynaActionForm )form; ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); I then added a number of properties with pre-defined values to the ThreadBean in the Action class: Timestamp now = DateUtil.getCurrentGMTTimestamp(); threadBean.setThreadCreationDate( now ); threadBean.setThreadViewCount( 0 ); I then called a method in a service class ThreadHandler and passing threadBean as the parameter of that method: ThreadHandler thandler = new ThreadHandler(); threadID = thandler.insertThread( threadBean ); In the ThreadHandler class (see below), I first tried to retrieve the values of those properties from the ThreadBean. I FOUND OUT ALL THOSE VALUES ARE NULL! class ThreadHandler extends ThreadBean { int threadID = getThreadID(); String receiver = getReceiver(); String sender = getSender(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); public ThreadHandler() {} MessageDAO md = new MySQLMessageDAO(); public int insertThread( ThreadBean threadBean ) throws MessageDAOSysException, ObjectNotFoundException { md.createThread( receiver, sender, threadCreationDate, threadViewCount ); . . return threadID; } } __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm)
What does BeanUtils.populate(); do? I used BeanUtils.copyProperties(); Does it make any difference? --- Robert Taylor [EMAIL PROTECTED] wrote: Have you checked to make sure that the fields you expect actually exist in the form before calling BeanUtils.populate()? If so, have you checked to see if the data was copied properly just after BeanUtils.populate()? BeanUtils.populate() uses reflection to copy properties. Are you usingproper JavaBeans naming convention? Try and isolate exactly where the data is getting lost. I use BeanUtils.populate() all the time with DynaForms and have no problems. Usually when I do, I find that my data member names don't correspond. robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 1:42 PM To: [EMAIL PROTECTED] Subject: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm) Hi, my program compiled OKay. When I ran the application, somehow, the properties of my DynaValidatorForm are not passed from the action class to the business tier and then to the data access tier. Please help me taking a look at what went wrong. It looks that the validation worked fine: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ . . /form-bean because when I intentionally left several of the text fields blank and submitted my JSP form, an applet got prompted showing something in those fields are required. In my action class (see below), I used BeanUtils to copy all the properties of the DynaValidatorForm to a bean (ThreadBean): DynaActionForm postForm = ( DynaActionForm )form; ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); I then added a number of properties with pre-defined values to the ThreadBean in the Action class: Timestamp now = DateUtil.getCurrentGMTTimestamp(); threadBean.setThreadCreationDate( now ); threadBean.setThreadViewCount( 0 ); I then called a method in a service class ThreadHandler and passing threadBean as the parameter of that method: ThreadHandler thandler = new ThreadHandler(); threadID = thandler.insertThread( threadBean ); In the ThreadHandler class (see below), I first tried to retrieve the values of those properties from the ThreadBean. I FOUND OUT ALL THOSE VALUES ARE NULL! class ThreadHandler extends ThreadBean { int threadID = getThreadID(); String receiver = getReceiver(); String sender = getSender(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); public ThreadHandler() {} MessageDAO md = new MySQLMessageDAO(); public int insertThread( ThreadBean threadBean ) throws MessageDAOSysException, ObjectNotFoundException { md.createThread( receiver, sender, threadCreationDate, threadViewCount ); . . return threadID; } } __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus - 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] __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm)
I have narrowed down the problem. Something went wrong in my business tier class (ThreadHandler.java). All the properties in the JavaBean are populated properly (I have checked). The way I coded in the ThreadHandler class failed to retrieve the value of all the properties in the JavaBean (ThreadBean.java). All the values turned out to be null or 0. Now, what is wrong with the code? class ThreadHandler extends ThreadBean { String receiver = getReceiver(); String sender = getSender(); String threadTopic = getPostTopic(); String threadBody = getPostBody(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); int threadReplyCount = getThreadReplyCount(); . . } To answer your question: 1. Have you checked to make sure that the fields you expect actually exist in the form before calling BeanUtils.copyProperties()? Yes, I have printed out the contents of the JSP text fields in my action class, which is a servlet. For example: System.out.println( the sender is + postForm.get( sender ) ); 2. If so, have you checked to see if the data was copied properly just after BeanUtils.copyProperties()? Yes, I have also printed out the value of the bean properties. For example: System.out.println( the sender is + threadBean.getSender() ); 3. BeanUtils.copyProperties() uses reflection to copy properties. Are you using proper JavaBeans naming convention? Yes, I used a pair of get and set methods for each properties in the JavaBean (ThreadBean.java). And in my action class, I could print out the value of those properties. --- Robert Taylor [EMAIL PROTECTED] wrote: Have you checked to make sure that the fields you expect actually exist in the form before calling BeanUtils.populate()? If so, have you checked to see if the data was copied properly just after BeanUtils.populate()? BeanUtils.populate() uses reflection to copy properties. Are you usingproper JavaBeans naming convention? Try and isolate exactly where the data is getting lost. I use BeanUtils.populate() all the time with DynaForms and have no problems. Usually when I do, I find that my data member names don't correspond. robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 1:42 PM To: [EMAIL PROTECTED] Subject: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm) Hi, my program compiled OKay. When I ran the application, somehow, the properties of my DynaValidatorForm are not passed from the action class to the business tier and then to the data access tier. Please help me taking a look at what went wrong. It looks that the validation worked fine: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ . . /form-bean because when I intentionally left several of the text fields blank and submitted my JSP form, an applet got prompted showing something in those fields are required. In my action class (see below), I used BeanUtils to copy all the properties of the DynaValidatorForm to a bean (ThreadBean): DynaActionForm postForm = ( DynaActionForm )form; ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); I then added a number of properties with pre-defined values to the ThreadBean in the Action class: Timestamp now = DateUtil.getCurrentGMTTimestamp(); threadBean.setThreadCreationDate( now ); threadBean.setThreadViewCount( 0 ); I then called a method in a service class ThreadHandler and passing threadBean as the parameter of that method: ThreadHandler thandler = new ThreadHandler(); threadID = thandler.insertThread( threadBean ); In the ThreadHandler class (see below), I first tried to retrieve the values of those properties from the ThreadBean. I FOUND OUT ALL THOSE VALUES ARE NULL! class ThreadHandler extends ThreadBean { int threadID = getThreadID(); String receiver = getReceiver(); String sender = getSender(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); public ThreadHandler() {} MessageDAO md = new MySQLMessageDAO(); public int insertThread( ThreadBean threadBean ) throws MessageDAOSysException, ObjectNotFoundException { md.createThread( receiver, sender, threadCreationDate, threadViewCount ); . . return threadID; } } __ Do you Yahoo!? Yahoo
Problem With Passing Properties of DynaValidatorForm to the Business Tier
Hi, my program compiled OKay. When I ran the application, somehow, the properties of my DynaValidatorForm are not passed from the action class to the business tier and then to the data access tier. Please help me taking a look at what went wrong. It looks that the validation worked fine: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ . . /form-bean because when I intentionally left several of the text fields blank and submitted my JSP form, an applet got prompted showing something in those fields are required. In my action class (see below), I used BeanUtils to copy all the properties of the DynaValidatorForm to a bean (ThreadBean): DynaActionForm postForm = ( DynaActionForm )form; ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); I then added a number of properties with pre-defined values to the ThreadBean in the Action class: Timestamp now = DateUtil.getCurrentGMTTimestamp(); threadBean.setThreadCreationDate( now ); threadBean.setThreadViewCount( 0 ); I then called a method in a service class ThreadHandler and passing threadBean as the parameter of that method: ThreadHandler thandler = new ThreadHandler(); threadID = thandler.insertThread( threadBean ); In the ThreadHandler class, I first tried to get the values of those properties out of the ThreadBean. It looked to me that the values of those properties are not retrieved and passed to the data access tier. class ThreadHandler extends ThreadBean { int threadID = getThreadID(); String receiver = getReceiver(); String sender = getSender(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); public ThreadHandler() {} MessageDAO md = new MySQLMessageDAO(); public int insertThread( ThreadBean threadBean ) throws MessageDAOSysException, ObjectNotFoundException { md.createThread( receiver, sender, threadCreationDate, readViewCount ); . . return threadID; } } __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please Help - ClassCastException
I am still confused... I have a jsp that provides text fields for user to fill out information. All the information is passed via HttpRequest and to be validated. And all the properties in my PostForm are populated by the information retrieved from those text fields. And my PostForm is of type=org.apache.struts.validator.DynaValidatorForm Therefore, in my PostForm.java, I should do something like this? I just do not think the following code is correct. == import org.apache.struts.validator.DynaValidatorForm; public class PostForm extends DynaValidatorForm { private String receiver; private String sender; public void set(String receiver, String receiver); public void set(String sender, String sender); public String get(String receiver, String receiver); public String get(String sender, String sender); } == And you are saying that in my action class, I should ... import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.commons.beanutils.BeanUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.artimus.message.PostForm; import org.apache.artimus.message.PostBean; import org.apache.artimus.message.ThreadBean; import org.apache.artimus.message.utility.DateUtil; public final class StoreMessage extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int parentPostID; int threadID; String memberName = request.getRemoteUser(); Timestamp now = DateUtil.getCurrentGMTTimestamp(); parentPostID = Integer.parseInt( request.getParameter( parent ) ); ActionForm postForm = ( ActionForm )form; ThreadHandler thandler = new ThreadHandler(); ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); if (parentPostID == 0 ) // new topic { threadBean.setLastPostMemberName( memberName ); threadBean.setThreadCreationDate( now ); . . threadID = thandler.insertThread( threadBean ); } ... ... } } --- Joe Hertz [EMAIL PROTECTED] wrote: Well, first off: In your (dyna) form, you don't create setters and getters for the properties though. With DynaForms you would say set(myPropertyName, myString) instead of calling setMyPropertyName(myString). This is the Dyna part of DynaForms. It's much less tedious IMHO. In your action, you absolutely want to cast the form to PostForm. Otherwise the form variable has no way to know properties are associated with it. So yes, once you cast it to PostForm calls to BeanUtils.copyProperties() can and will work properly. Hope this helps, -Joe -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Sunday, January 04, 2004 1:42 AM To: Struts Users Mailing List Subject: RE: Please Help - ClassCastException I think that there are a lot more mistakes in my code than I originally thought. The root of the problem is that I do not know how to use DynaValidatorForm. If you could help me in learning how to code when I am working with DynaValidatorForm. 1. in my struts-config.xml, I have: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ . . /form-bean 2. My PostForm.java is like: import org.apache.struts.validator.DynaValidatorForm; import org.apache.struts.action.ActionMapping; public class PostForm extends DynaValidatorForm { private String receiver; private String sender; .. public void setReceiver( String receiver ) { this.receiver = receiver; } public void setSender( String sender ) { this.sender = sender; } public String getReceiver() { return receiver; } public String getSender() { return sender; } . . } 3. in my action class (see the code below) 3.1. do I cast the form to DynaActionForm? or I should cast the form to DynaValidatorForm? 3.2. Can I use the copyProperties() method of the BeanUtils to convert the form to a bean? BeanUtils.copyProperties
RE: Please Help - ClassCastException
Allow me to ask three more questions: 1. If I want to reset some specific text fields when the JSP is re-displayed, do I code the PostForm.java like this (please confirm): code: - import org.apache.struts.validator.DynaValidatorForm; import org.apache.struts.action.ActionMapping; import javax.servlet.http.HttpServletRequest; public class PostForm extends DynaValidatorForm { public void reset(ActionMapping mapping, HttpServletRequest request) { super.reset( mapping, request ); set( receiver, new String() ); set( sender, new String() ); } public PostForm () {} } --- 2. if I want to reset all the text fields when the JSP is re-displayed, do I code like this (please confirm): code: --- import org.apache.struts.validator.DynaValidatorForm; import org.apache.struts.action.ActionMapping; import javax.servlet.http.HttpServletRequest; public class PostForm extends DynaValidatorForm { public void reset(ActionMapping mapping, HttpServletRequest request) { initialize( mapping ); } public PostForm () {} } -- 3. What is the difference between code: --- form-bean name=postForm type=package.package.package.PostForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ /form-bean --- AND code: -- form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ /form-bean --- Thank you very much. --- Joe Hertz [EMAIL PROTECTED] wrote: Not at all. First off, set(String, String) is predefined for you. You don't need to create any of that. In fact, what you will find in a DynaValidatorForm is that your form classes start to get very sparse. Here's really what it could look like. public class PostForm extends BaseDynaForm { public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { // throw new UnsupportedOperationException(Method is not implemented); } public PostForm () { } } In your ActionForm itself, beanUtils would work something like this. All you need is to get the right formBean object. public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PostForm pForm = (PostForm) form; // other code you write here BeanUtils.copyProperties(yourBean, pForm); // etc Doing it yourself without beanUtils? Instead of calling getSender() and having a String returned, you call get (sender) and it will return an Object (cast it yourself to whatever type the sender form property really is). I made a base form class with a getString method that calls get() and does the String cast for me to save the tediom. Making sense now? -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Sunday, January 04, 2004 2:46 AM To: Struts Users Mailing List Subject: RE: Please Help - ClassCastException I am still confused... I have a jsp that provides text fields for user to fill out information. All the information is passed via HttpRequest and to be validated. And all the properties in my PostForm are populated by the information retrieved from those text fields. And my PostForm is of type=org.apache.struts.validator.DynaValidatorForm Therefore, in my PostForm.java, I should do something like this? I just do not think the following code is correct. == import org.apache.struts.validator.DynaValidatorForm; public class PostForm extends DynaValidatorForm { private String receiver; private String sender; public void set(String receiver, String receiver); public void set(String sender, String sender); public String get(String receiver, String receiver); public String get(String sender, String sender); } == And you are saying that in my action class, I should ... import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import
Please Help - ClassCastException
The statement shown below encountered a ClassCastException: PostForm postForm = ( PostForm )form; I cannot figure out the reason. Please help. Allow me to show more code of the class where the exception occurred: ... import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.commons.beanutils.BeanUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.artimus.message.PostBean; import org.apache.artimus.message.ThreadBean; import org.apache.artimus.message.utility.DateUtil; public final class StoreMessage extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int parentPostID; int threadID; int postID; String postCreationIP; String memberName = request.getRemoteUser(); Timestamp now = DateUtil.getCurrentGMTTimestamp(); parentPostID = Integer.parseInt( request.getParameter( parent ) ); PostForm postForm = ( PostForm )form; } } __ Do you Yahoo!? Find out what made the Top Yahoo! Searches of 2003 http://search.yahoo.com/top2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Please Help - ClassCastException
Thank you for trying to help. I have added import org.apache.artimus.message.PostForm; to my action class. I do not fully follow what I should check in the struts-config.xml file. And should I use name=postForm with lowercase 'p' or uppercase 'P'? In my struts-config.xml file, I have: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ form-property name=title type=java.lang.String/ form-property name=postTopic type=java.lang.String/ form-property name=postBody type=java.lang.String/ /form-bean and action roles=administrator,editor,contributor path=/message/NewTopic type=org.apache.artimus.message.StoreMessage name=postForm scope=request validate=true input=.message.Form forward name=success path=.article.View/ /action Do you see any problems? --- Pedro Salgado [EMAIL PROTECTED] wrote: On your struts config file check if the form bean for StoreMessage action is of type pkg.pkg.PostForm and if the action name is pointing to the correct form bean... It also seems to be missing the import of the PostForm on your action class. Pedro Salgado On 04/01/2004 03:22, Caroline Jen [EMAIL PROTECTED] wrote: The statement shown below encountered a ClassCastException: PostForm postForm = ( PostForm )form; I cannot figure out the reason. Please help. Allow me to show more code of the class where the exception occurred: ... import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.commons.beanutils.BeanUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.artimus.message.PostBean; import org.apache.artimus.message.ThreadBean; import org.apache.artimus.message.utility.DateUtil; public final class StoreMessage extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int parentPostID; int threadID; int postID; String postCreationIP; String memberName = request.getRemoteUser(); Timestamp now = DateUtil.getCurrentGMTTimestamp(); parentPostID = Integer.parseInt( request.getParameter( parent ) ); PostForm postForm = ( PostForm )form; } } __ Do you Yahoo!? Find out what made the Top Yahoo! Searches of 2003 http://search.yahoo.com/top2003 - 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] __ Do you Yahoo!? Find out what made the Top Yahoo! Searches of 2003 http://search.yahoo.com/top2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please Help - ClassCastException
I think that there are a lot more mistakes in my code than I originally thought. The root of the problem is that I do not know how to use DynaValidatorForm. If you could help me in learning how to code when I am working with DynaValidatorForm. 1. in my struts-config.xml, I have: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ . . /form-bean 2. My PostForm.java is like: import org.apache.struts.validator.DynaValidatorForm; import org.apache.struts.action.ActionMapping; public class PostForm extends DynaValidatorForm { private String receiver; private String sender; .. public void setReceiver( String receiver ) { this.receiver = receiver; } public void setSender( String sender ) { this.sender = sender; } public String getReceiver() { return receiver; } public String getSender() { return sender; } . . } 3. in my action class (see the code below) 3.1. do I cast the form to DynaActionForm? or I should cast the form to DynaValidatorForm? 3.2. Can I use the copyProperties() method of the BeanUtils to convert the form to a bean? BeanUtils.copyProperties( threadBean, postForm ); ... import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.struts.action.DynaActionForm; import org.apache.commons.beanutils.BeanUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.artimus.message.PostForm; import org.apache.artimus.message.PostBean; import org.apache.artimus.message.ThreadBean; import org.apache.artimus.message.utility.DateUtil; public final class StoreMessage extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int parentPostID; int threadID; String memberName = request.getRemoteUser(); Timestamp now = DateUtil.getCurrentGMTTimestamp(); parentPostID = Integer.parseInt( request.getParameter( parent ) ); DynaActionForm postForm = ( DynaActionForm )form; ThreadHandler thandler = new ThreadHandler(); ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); if (parentPostID == 0 ) // new topic { threadBean.setLastPostMemberName( memberName ); threadBean.setThreadCreationDate( now ); . . threadID = thandler.insertThread( threadBean ); } ... ... } } 4. the action mapping in my struts-config.xml is like: action roles=administrator,editor,contributor path=/message/NewTopic type=org.apache.artimus.message.StoreMessage name=postForm scope=request validate=true input=.message.Form forward name=success path=.article.View/ /action Thank you. --- David Friedman [EMAIL PROTECTED] wrote: Here is what I see (opinions vary)... I see you are defining your form bean in your struts-config.xml as type 'org.apache.struts.validator.DynaValidatorForm'. So, why are you trying to cast it as this 'org.apache.artimus.message.PostForm' class. Does that class extend DynaValidatorForm? If it doesn't, you'll get a ClassCastException like you're getting now. Personally, I expected you to cast it as: DynaValidatorForm postForm = (DynaValidatorForm) form; Or us it as-initially defined (not casting like above) and use BeanUtils such as: String receiver = (String) PropertyUtils.getSimpleProperty(form, receiver); Regards, David -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Saturday, January 03, 2004 11:04 PM To: Struts Users Mailing List Subject: Re: Please Help - ClassCastException Thank you for trying to help. I have added import org.apache.artimus.message.PostForm; to my action class. I do not fully follow what I should check in the struts-config.xml file. And should I use name=postForm with lowercase 'p' or uppercase 'P'? In my struts-config.xml file, I have: form-bean name=postForm type=org.apache.struts.validator.DynaValidatorForm form-property name=receiver type=java.lang.String/ form-property name=sender type=java.lang.String/ form-property name
Bean As A Parameter In A Method - Compilation Error
I followed the MVC design. I give the data access activity (insertThread) to the ThreadHandler class. And a bean is passed as a parameter of the insertThread method. However, I got compilation error saying that insertThread(java.lang.String, java.lang.String, ... , java.sql.Timastamp, int, ... ) cannto be applied to the ThreadBean. and the error complains the statement in my action class: threadID = thandler.insertThread( threadBean ); This is what I did in the action class: ThreadHandler thandler = new ThreadHandler(); ThreadBean threadBean = new ThreadBean(); BeanUtils.copyProperties( threadBean, postForm ); if (parentPostID == 0 ) // new topic { threadBean.setLastPostMemberName( memberName ); threadBean.setThreadCreationDate( now ); threadBean.setThreadViewCount( 0 ); threadBean.setThreadReplyCount( 0 ); threadID = thandler.insertThread( threadBean ); } and this is what I did in the ThreadHandler class: class ThreadHandler extends ThreadBean { String receiver = getReceiver(); String sender = getSender(); String title = getTitle(); String lastPostMemberName = getLastPostMemberName(); String threadTopic = getThreadTopic(); String threadBody = getThreadBody(); Timestamp threadCreationDate = getThreadCreationDate(); int threadViewCount = getThreadViewCount(); int threadReplyCount = getThreadReplyCount(); public ThreadHandler() {} public int insertThread( String receiver, String sender, String title, String lastPostMemberName, String threadTopic, String threadBody, Timestamp threadCreationDate, int threadViewCount, int threadReplyCount ) throws MessageDAOSysException { } } __ Do you Yahoo!? Find out what made the Top Yahoo! Searches of 2003 http://search.yahoo.com/top2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How Do I Handle Two Action Forms
I am stuck and need your knowledge and experience. When the button is my JSP is clicked, there are two action forms involved, threadForm and postForm. The threadForm is populated by hidden fields and text fields that are passed from the JSP. All the properties of the threadForm are to be inserted into a table in the database by the threadInsert() method and this method returns a primitive int threadID. The properties in the postForm are also populated by hidden fields and text fields that are passed from the same JSP, except that the postForm has one additional properties - threadID, which is obtained from the insertion of the threadForm into the database. Thereafter, all the properties of the postForm are to be inserted into another table in the database by the postInsert() method. How do I handle this situation? Please help. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validation
One simple question - if my form bean is of the DynaValidatorForm type in the struts-config.xml and each propery of the form is specified in the validation.xml, do I have to call the validate method in the form bean? E.g. Do I still have to do the following in my form bean that extends the ActionForm? public ActionErrors validate( ActionMapping mapping, HttpServletRequest request ) { ActionErrors errors = new ActionErrors(); if ( getSender() == null || getSender().length() 1 ) { errors.add( sender,new ActionError( error.sender.required ) ); } } __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Form and Pass the Form to the Business Tier
My JSP provides several text fields for visitors to fill out. And my form bean stores those information; for example: public String getThreadTopic() { return threadTopic; } public void setThreadTopic(String threadTopic) { this.threadTopic = threadTopic; } public String getThreadBody() { return threadBody; } public void setThreadBody(String threadBody) { this.threadBody = threadBody; } However, I have to supply a number of additional properties for the business tier to process. For example, the property threadType is to be assigned to zero manually and the property parentPostID is to be found from another class, how do I code them in the form bean? Do I use get methods shown below (without set methods)? public int getThreadType() { return 0; } public int getParentPostID() { return ParamUtil.getParameterInt( request, parent ); } __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form and Pass the Form to the Business Tier
Thank you for your response. According to my understanding of your advice, if I want to pass a hidden field from JSP to a form bean, I must have name=myFormName in the JSP's html:hidden tag? Please confirm. Another additional property that is to be assigned a value in my form bean is now with Timestamp type. Do I code this way in my form bean class? Please confirm: pubic Timestamp getNow() { return DateUtil.getCurrentGMTTimestamp(): } -Caroline --- David Erickson [EMAIL PROTECTED] wrote: However, I have to supply a number of additional properties for the business tier to process. For example, the property threadType is to be assigned to zero manually and the property parentPostID is to be found from another class, how do I code them in the form bean? Do I use get methods shown below (without set methods)? public int getThreadType() { return 0; } This is fine I assume. public int getParentPostID() { return ParamUtil.getParameterInt( request, parent ); } This wouldn't work properly. I would make a setter for parentPostID and in the jsp write something like: html:hidden name=yourformname property=parentPostID value=%= request.getParameter(parent)%/ HTH, David - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Is Hidden Field Passed As a String?
I am passing a hidden field from my JSP to my form bean: html:hidden name=postForm property=parent value=0/ Is the property parent considered a String in the form bean? Do I have to use BeanUtils.copyProperties( postDTO, postForm ); to convert that property to a primitive type int? __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How To Output the Value of a String That Is Passed From Another JSP?
Thank you for your time and support. It is the JSTL taglib directive I missed in my page. Now, everything works as expected. --- Robert Taylor [EMAIL PROTECTED] wrote: I bet your missing the JSTL taglib directive in your page. Try adding %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % and then your c:x .../ actions will work. -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 9:45 PM To: Struts Users Mailing List Subject: RE: How To Output the Value of a String That Is Passed From Another JSP? Thanks for your advice. I did this in my view.jsp: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ c:out value=${cr}/ html:submitView/Send Messages/html:submit /html:form bean:write name=articleForm property=creator/ I was able to see the View/Send Messages button displayed. And the bean:write name=articleForm property=creator/ also wrote out the value of the property creator. Now, the question is 1. why the c:set var=cr value=${articleForm.creator} scope=session/ did not put the value in the session scope? 2. What is wrong with the c:set tag? 3. What should I do if I want to put the value of creator in a session scope? -C --- Robert Taylor [EMAIL PROTECTED] wrote: Are you sure that c:set var=cr value=${articleForm.creator} scope=session/ is placing the value in the intended scope? Try doing this: html:form action=/list/Message c:set var=cr value=${articleForm.creator}scope=session/ c:out value=${cr}/ html:submitView/Send Messages/html:submit /html:form To make sure it is actually putting the value in session scope. If so, then on postForm.jsp try using scriplets to make sure that the value can be accessed. If it can, then do you have all of your tag library directives in your pages? robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 8:40 PM To: Struts Users Mailing List Subject: RE: How To Output the Value of a String That Is Passed From Another JSP? cr is not a form and there is no action involved. There are two JSPs; view.jsp and postForm.jsp and each is with its own form (different forms). In my view.jsp, I am able to write out String creator this way: bean:write name=articleForm property=creator/ and I put the String creator in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form and in the postForm.jsp, I retrieve the String and try to write it out in a text field: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ I got this error message: ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' -Caroline --- David Friedman [EMAIL PROTECTED] wrote: Caroline, How do you save the form cr in session scope? Does your action use 'scope=session' or are you doing a 'request.getSession().setAttribute(cr,cr);' in the first action? Regards, David -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 8:25 PM To: Struts Users Mailing List Subject: RE: How To Output the Value of a String That Is Passed From Another JSP? Hi, my JSP#1 and JSP#2 use different forms. However, property name in JSP#1 is the same as that in JSP#2. I tried to pass this Sring and write it out in a text field in JSP#2 and just could not get it right. I got this error message: [ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' In my view.jsp, I put a String in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form And in postForm.jsp, I tried to retrieve that String and write it out in a text field this way: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ -Caroline --- Robert Taylor [EMAIL PROTECTED] wrote: === message truncated === __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http
Re: Please Help With This Error Message
Hi, I tried and tried. I cannot figure out the error. I need your sharp eyes and experience. I keep getting this error message in the browser: ServletException in:/article/content/postForm.jsp] /article/content/postForm.jsp(32,67) equal symbol expected' This postForm.jsp had worked find before I inserted: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=bean:write name=author/ size=82 maxlength=25 tabindex=1/ And the error message points at the bean:define ... tag. The statements are in ONE line (they do not wrapped around) in my file. cr is passed to the postForm.jsp in a session object this way: c:set var=cr value=${articleForm.creator} scope=session/ Thanks a lot. -C --- Firat TIRYAKI [EMAIL PROTECTED] wrote: maybe you don't have a space character between creator and scope... try to write the tag in one line, not multiple lines. F. - Original Message - From: fredatwork [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 8:53 AM Subject: RE: Please Help With This Error Message Your statement is OK. It comes from the surrounding quote. The only idea I have is to check double-quotes correctly. Fred -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: mercredi 17 décembre 2003 07:41 To: [EMAIL PROTECTED] Subject: Please Help With This Error Message Please help me to figure out this error message that I got in the browser: equal symbol expected. The error complains about this statement in my JSP: bean:define id=author name=creator scope=session type=java.lang.String/ and the above statement is intended to retrieve the string creator from a session object. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Error When Trying to Pass A String From One JSP To Another JSP
Please help me. I have tried to do it for days. I just could not get it right. I got this error message: [ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' In my view.jsp, I put a String in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form And in postForm.jsp, I tried to retrieve that String and write it out in a text field: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How To Output the Value of a String That Is Passed From Another JSP?
Hi, my JSP#1 and JSP#2 use different forms. However, property name in JSP#1 is the same as that in JSP#2. I tried to pass this Sring and write it out in a text field in JSP#2 and just could not get it right. I got this error message: [ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' In my view.jsp, I put a String in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form And in postForm.jsp, I tried to retrieve that String and write it out in a text field this way: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ -Caroline --- Robert Taylor [EMAIL PROTECTED] wrote: There are a couple (3) ways to do it. 1. Have both JSP#1 and 2 use the same form then have the action that processes JSP#1 simply forward to JSP#2 and Struts will auto-populate the field. 2. Have the action that processes JSP#1 forward or redirect to JSP#2 whose form has the same property name. Place the create property value in the query string and Struts will auto-populate the form in JSP#2. 3. Have the action that processes JSP#1 access and populate the form used in JSP#2 with the property then forward to JSP#2. robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 8:33 PM To: [EMAIL PROTECTED] Subject: How To Output the Value Of a Hidden Field? My JSP #2 receives a hidden field passed from JSP #1: html:hidden property=creator/ In the JSP #2, I have a text field: html:text property=creator size=82 maxlength=25 tabindex=1/ and I want the value of the hidden field to be the text in the text field of the JSP #2. Please advise how to do it? __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How To Output the Value of a String That Is Passed From Another JSP?
cr is not a form and there is no action involved. There are two JSPs; view.jsp and postForm.jsp and each is with its own form (different forms). In my view.jsp, I am able to write out String creator this way: bean:write name=articleForm property=creator/ and I put the String creator in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form and in the postForm.jsp, I retrieve the String and try to write it out in a text field: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ I got this error message: ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' -Caroline --- David Friedman [EMAIL PROTECTED] wrote: Caroline, How do you save the form cr in session scope? Does your action use 'scope=session' or are you doing a 'request.getSession().setAttribute(cr,cr);' in the first action? Regards, David -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 8:25 PM To: Struts Users Mailing List Subject: RE: How To Output the Value of a String That Is Passed From Another JSP? Hi, my JSP#1 and JSP#2 use different forms. However, property name in JSP#1 is the same as that in JSP#2. I tried to pass this Sring and write it out in a text field in JSP#2 and just could not get it right. I got this error message: [ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' In my view.jsp, I put a String in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form And in postForm.jsp, I tried to retrieve that String and write it out in a text field this way: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ -Caroline --- Robert Taylor [EMAIL PROTECTED] wrote: There are a couple (3) ways to do it. 1. Have both JSP#1 and 2 use the same form then have the action that processes JSP#1 simply forward to JSP#2 and Struts will auto-populate the field. 2. Have the action that processes JSP#1 forward or redirect to JSP#2 whose form has the same property name. Place the create property value in the query string and Struts will auto-populate the form in JSP#2. 3. Have the action that processes JSP#1 access and populate the form used in JSP#2 with the property then forward to JSP#2. robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 8:33 PM To: [EMAIL PROTECTED] Subject: How To Output the Value Of a Hidden Field? My JSP #2 receives a hidden field passed from JSP #1: html:hidden property=creator/ In the JSP #2, I have a text field: html:text property=creator size=82 maxlength=25 tabindex=1/ and I want the value of the hidden field to be the text in the text field of the JSP #2. Please advise how to do it? __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How To Output the Value of a String That Is Passed From Another JSP?
Thanks for your advice. I did this in my view.jsp: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ c:out value=${cr}/ html:submitView/Send Messages/html:submit /html:form bean:write name=articleForm property=creator/ I was able to see the View/Send Messages button displayed. And the bean:write name=articleForm property=creator/ also wrote out the value of the property creator. Now, the question is 1. why the c:set var=cr value=${articleForm.creator} scope=session/ did not put the value in the session scope? 2. What is wrong with the c:set tag? 3. What should I do if I want to put the value of creator in a session scope? -C --- Robert Taylor [EMAIL PROTECTED] wrote: Are you sure that c:set var=cr value=${articleForm.creator} scope=session/ is placing the value in the intended scope? Try doing this: html:form action=/list/Message c:set var=cr value=${articleForm.creator}scope=session/ c:out value=${cr}/ html:submitView/Send Messages/html:submit /html:form To make sure it is actually putting the value in session scope. If so, then on postForm.jsp try using scriplets to make sure that the value can be accessed. If it can, then do you have all of your tag library directives in your pages? robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 8:40 PM To: Struts Users Mailing List Subject: RE: How To Output the Value of a String That Is Passed From Another JSP? cr is not a form and there is no action involved. There are two JSPs; view.jsp and postForm.jsp and each is with its own form (different forms). In my view.jsp, I am able to write out String creator this way: bean:write name=articleForm property=creator/ and I put the String creator in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form and in the postForm.jsp, I retrieve the String and try to write it out in a text field: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ I got this error message: ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' -Caroline --- David Friedman [EMAIL PROTECTED] wrote: Caroline, How do you save the form cr in session scope? Does your action use 'scope=session' or are you doing a 'request.getSession().setAttribute(cr,cr);' in the first action? Regards, David -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 8:25 PM To: Struts Users Mailing List Subject: RE: How To Output the Value of a String That Is Passed From Another JSP? Hi, my JSP#1 and JSP#2 use different forms. However, property name in JSP#1 is the same as that in JSP#2. I tried to pass this Sring and write it out in a text field in JSP#2 and just could not get it right. I got this error message: [ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' In my view.jsp, I put a String in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form And in postForm.jsp, I tried to retrieve that String and write it out in a text field this way: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ -Caroline --- Robert Taylor [EMAIL PROTECTED] wrote: There are a couple (3) ways to do it. 1. Have both JSP#1 and 2 use the same form then have the action that processes JSP#1 simply forward to JSP#2 and Struts will auto-populate the field. 2. Have the action that processes JSP#1 forward or redirect to JSP#2 whose form has the same property name. Place the create property value in the query string and Struts will auto-populate the form in JSP#2. 3. Have the action that processes JSP#1 access and populate the form used in JSP#2 with the property then forward to JSP#2. robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 8:33 PM To: [EMAIL PROTECTED] Subject: How To Output the Value Of a Hidden Field? My JSP #2 receives a hidden field passed from JSP #1: html:hidden property=creator/ In the JSP #2, I have a text field: html:text property=creator size=82 maxlength=25 tabindex=1
RE: How To Output the Value of a String That Is Passed From Another JSP?
Hi, thank you for your attention to my problem. First all, I think that I am missing someting. In order to use the c:set and c:out ... tags, I think that I have to import a taglib into my JSP and assign it with a prefix c. Which taglib should I import? Right now, I have these: %@ taglib uri=/tags/struts-html prefix=html % %@ taglib uri=/tags/struts-bean prefix=bean % %@ taglib uri=/tags/struts-logic prefix=logic % %@ taglib uri=/tags/tiles prefix=tiles % %@ taglib uri=/tags/request prefix=req % Second, html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ c:out value=${cr}/ html:submitView/Send Messages/html:submit /html:form %-- The statement below has no problem to write on the value --% bean:write name=articleForm property=creator/ Third, the mapping to the next JSP is: action roles=administrator,editor,contributor path=/list/Message forward=.message.Form name=postForm scope=session validate=false/ Fourth, in the postForm.jsp, I try to retrieve the value of the String that is passed in a session object and print it out in a text field: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ Fifth, the error message is that cr cannot be found in the session scope. -Caroline --- Robert Taylor [EMAIL PROTECTED] wrote: What exactly are you trying to accomplish? What's the high level view? If you can explain your intent, maybe we can suggest an easier way to accomplish your goal. Is articleForm associated with action mapping /list/Message? If so, then you could do something like: html:form action=/list/Message html:hidden property=creator/ html:submitView/Send Messages/html:submit /html:form This of course, assumes you have already populated creator in articleForm in some other action using the same form. The action with mapping /list/Message, which processes articleForm could do something like: MyForm articleForm = (MyForm) form; String creator = articleForm.getCreator(); request.getSession().setAttribute(creator, creator); return mapping.findForward(success); In JSP#2 you could do something like this: c:out value=${creator}/ robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 8:25 PM To: Struts Users Mailing List Subject: RE: How To Output the Value of a String That Is Passed From Another JSP? Hi, my JSP#1 and JSP#2 use different forms. However, property name in JSP#1 is the same as that in JSP#2. I tried to pass this Sring and write it out in a text field in JSP#2 and just could not get it right. I got this error message: [ServletException in:/article/content/postForm.jsp] Cannot find bean cr in scope session' In my view.jsp, I put a String in a session object: html:form action=/list/Message c:set var=cr value=${articleForm.creator} scope=session/ html:submitView/Send Messages/html:submit /html:form And in postForm.jsp, I tried to retrieve that String and write it out in a text field this way: bean:define id=author name=cr scope=session type=java.lang.String/ html:text property=creator value=%=author% size=82 maxlength=25 tabindex=1/ -Caroline --- Robert Taylor [EMAIL PROTECTED] wrote: There are a couple (3) ways to do it. 1. Have both JSP#1 and 2 use the same form then have the action that processes JSP#1 simply forward to JSP#2 and Struts will auto-populate the field. 2. Have the action that processes JSP#1 forward or redirect to JSP#2 whose form has the same property name. Place the create property value in the query string and Struts will auto-populate the form in JSP#2. 3. Have the action that processes JSP#1 access and populate the form used in JSP#2 with the property then forward to JSP#2. robert -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 8:33 PM To: [EMAIL PROTECTED] Subject: How To Output the Value Of a Hidden Field? My JSP #2 receives a hidden field passed from JSP #1: html:hidden property=creator/ In the JSP #2, I have a text field: html:text property=creator size=82 maxlength=25 tabindex=1/ and I want the value of the hidden field to be the text in the text field of the JSP #2. Please advise how to do it? __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
Hidden Field
I tried to create a variable, assign a value to that variable, and pass the variable as a hidden field. What I did was: html:hidden property=parent value=0 Why do I get this error message in the browser? 'According to TLD, tag html:hidden must be empty, but is not' __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How To Output the Value Of a Hidden Field?
My JSP #2 receives a hidden field passed from JSP #1: html:hidden property=creator/ In the JSP #2, I have a text field: html:text property=creator size=82 maxlength=25 tabindex=1/ and I want the value of the hidden field to be the text in the text field of the JSP #2. Please advise how to do it? __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Please Help With This Error Message
Please help me to figure out this error message that I got in the browser: equal symbol expected. The error complains about this statement in my JSP: bean:define id=author name=creator scope=session type=java.lang.String/ and the above statement is intended to retrieve the string creator from a session object. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Form and Session
The statement below in my JSP can write out the value of the creator property in the articleForm: bean:write name=articleForm property=creator/ I want to pass the value of the creator in a session object. What should I do in my JSP? % String creator = (String)articleForm.getCreator; session.setAttribute(creator, creator); % Or, can I pass articleForm in a session object? % session.setAttribute(articleForm, articleForm);% __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction
Hi, I think that we are in different time zones. As you have mentioned, I, too, suspected that the statement in my JSP: request.getRemoteUser(); returns nothing. Therefore, I did a test in my JSP. In addition to request.getRemoteUser(); I created another String manually: req:isUserInRole role=editor % String username = request.getRemoteUser(); String userrole = author; % % out.println(The user name is: + username +.); % % out.println(The role is: + userrole +.); % /req:isUserInRole And the browser shows: The user name is: Gloria Jen. The role is: author. Gloria Jen is the name that I provided while logging on and authenticated by the container. Therefore, the request.getRemoteUser(); does not return a null. And I hope that it means I am not passing a null value when I use the hidden field technique. Then, I pass two hidden fields (with value in them) from my JSP to a Java class (FindEditorData.java), which is of scaffold.ProcessAction type. One of the field is passed with its value correctly retrieved. The other field is passed with its value found to be null. What could go wrong? I have been thinking about it for days and so do those who try to help me. req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser(); String userrole = author; % %out.println(The user name is: + username +.);% %out.println(The role is: + userrole +.);% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole -Caroline --- Yee, Richard K,,DMDCWEST [EMAIL PROTECTED] wrote: Caroline, Imposible? Look at the HTML that is generated by the JSP page. I think you will see that it returns null. Take a look at the JavaDoc for HttpServletRequest.getRemoteUser(); getRemoteUser public java.lang.String getRemoteUser() Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER. Returns: a String specifying the login of the user making this request, or null As the JavaDoc says: Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Are you using basic authentication or are you authenticating the user yourself? If you are doing it yourself (ie. through a db lookup) then the server doesn't know about the user being authenticated and will return null. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 2:56 PM To: Struts Users Mailing List Subject: RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction I pass two hidden fields: username and keyName at the same time. The keyName is passed and with the correct value in it. The username is passed but its value turns out to be a null. It is impossible for request.getRemoteUser(); in my JSP returning a null. (see code below) Before it reaches request.getRemoteUser(); the user has already been successfully logged in with a valid name. req:isUserInRole role=editor html:form action=/find/Category TR TD class=option % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /TD /TR /html:form /req:isUserInRole --- Yee, Richard K,,DMDCWEST [EMAIL PROTECTED] wrote: Caroline, Are you having problems with the username or the keyName hidden variable? If it is the username, then I'd suspect that request.getRemoteUser() in your JSP is returning null. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 1:32 PM To: Struts Users Mailing List Subject: Re: Please Help! Unable to Pass A Hidden Field To scaffold.ProcessAction I did not mess up lowercase and uppercase of the hidden field I want to pass from my JSP to the scaffold.ProcessAction. If it had been the lowercase/uppercase problem, I would have gotten a message saying that the variable could not be recognized. I pass two hidden fields at the same time. One of them is successfully passed with correct value. The other is passed but its value shows a 'null' in the scaffold.ProcessAction. What could go wrong? Let me show my code again: Two hidden fields: username and keyName are passed from a JSP via a SUBMIT button: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username
RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction
I do not fully understand what you say about null or null. Anyway, I did try to write out values in the FindEditorData.java. What is written out in the browser is: name=null; kn=journal_category; kv=null And the way I try to write out those crucial fields is shown below: // package and import statements omitted public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData --- Richard Yee [EMAIL PROTECTED] wrote: Caroline, In your FindEditorData.java class, is the value for your username variable null or null? If it is null, then you are reading the wrong request parameter since request.getParameter() will return null if the parameter doesn't exist. If the String value is null, then you have a problem with getRemoteUser() Why don't you dump request parameters that you are getting in your FindEditorData? Hidden input tags work fine. Regards, Richard --- Caroline Jen [EMAIL PROTECTED] wrote: Hi, I think that we are in different time zones. As you have mentioned, I, too, suspected that the statement in my JSP: request.getRemoteUser(); returns nothing. Therefore, I did a test in my JSP. In addition to request.getRemoteUser(); I created another String manually: req:isUserInRole role=editor % String username = request.getRemoteUser(); String userrole = author; % % out.println(The user name is: + username +.); % % out.println(The role is: + userrole +.); % /req:isUserInRole And the browser shows: The user name is: Gloria Jen. The role is: author. Gloria Jen is the name that I provided while logging on and authenticated by the container. Therefore, the request.getRemoteUser(); does not return a null. And I hope that it means I am not passing a null value when I use the hidden field technique. Then, I pass two hidden fields (with value in them) from my JSP to a Java class (FindEditorData.java), which is of scaffold.ProcessAction type. One of the field is passed with its value correctly retrieved. The other field is passed with its value found to be null. What could go wrong? I have been thinking about it for days and so do those who try to help me. req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser(); String userrole = author; % %out.println(The user name is: + username +.);% %out.println(The role is: + userrole +.);% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole -Caroline --- Yee, Richard K,,DMDCWEST [EMAIL PROTECTED] wrote: Caroline, Imposible? Look at the HTML that is generated by the JSP page. I think you will see that it returns null. Take a look at the JavaDoc for HttpServletRequest.getRemoteUser(); getRemoteUser public java.lang.String getRemoteUser() Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER. Returns: a String specifying the login of the user making this request, or null As the JavaDoc says: Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Are you using basic authentication or are you authenticating the user yourself? If you are doing it yourself (ie. through a db lookup) then the server doesn't know about the user being authenticated and will return null. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 2:56 PM To: Struts Users Mailing List Subject: RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces
RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction
I followed your advice. In the Bean.java, I did the following: private String username = natalie; public String getUsername() { return this.username; } public void setUsername(String username) { this.username = username; } and I compiled all the relevant classes, re-run the application, the FindEditorData.java writes out the following in the browser: The process did not complete. Details should follow. name=natalie; kn=journal_category; kv=null Now, the question is why the Bean.java does not pick up the value of the hidden field 'username' from my JSP while successfully picks up the value of the other hidden field 'keyName'. There is some data processing activities going on in the FindEditorData.java: String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); The above data accessing codes had been tested outside the environment of the application (the codes did what I expected them to do without problem) before they were integrated into the application. -Caroline --- Richard Yee [EMAIL PROTECTED] wrote: Caroline, As a sanity check, in your bean, initialize the username variable to something ie. XX. and re-run your app. This will show if your setUsername is ever called. -Richard --- Caroline Jen [EMAIL PROTECTED] wrote: I do not fully understand what you say about null or null. Anyway, I did try to write out values in the FindEditorData.java. What is written out in the browser is: name=null; kn=journal_category; kv=null And the way I try to write out those crucial fields is shown below: // package and import statements omitted public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData --- Richard Yee [EMAIL PROTECTED] wrote: Caroline, In your FindEditorData.java class, is the value for your username variable null or null? If it is null, then you are reading the wrong request parameter since request.getParameter() will return null if the parameter doesn't exist. If the String value is null, then you have a problem with getRemoteUser() Why don't you dump request parameters that you are getting in your FindEditorData? Hidden input tags work fine. Regards, Richard --- Caroline Jen [EMAIL PROTECTED] wrote: Hi, I think that we are in different time zones. As you have mentioned, I, too, suspected that the statement in my JSP: request.getRemoteUser(); returns nothing. Therefore, I did a test in my JSP. In addition to request.getRemoteUser(); I created another String manually: req:isUserInRole role=editor % String username = request.getRemoteUser(); String userrole = author; % % out.println(The user name is: + username +.); % % out.println(The role is: + userrole +.); % /req:isUserInRole And the browser shows: The user name is: Gloria Jen. The role is: author. Gloria Jen is the name that I provided while logging on and authenticated by the container. Therefore, the request.getRemoteUser(); does not return a null. And I hope that it means I am not passing a null value when I use the hidden field technique. Then, I pass two hidden fields (with value in them) from my JSP to a Java class (FindEditorData.java), which is of scaffold.ProcessAction type. One of the field is passed with its value correctly retrieved. The other field is passed with its value found to be null. What could go wrong? I have been thinking about it for days and so do those who try to help me. req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser(); String userrole = author; % %out.println(The user
RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction
I did another test. I took out those data access activities in the FindEditorData.java and ran the application. The conclusion is that those few lines of data access activities have nothing to do with the value of the 'username' becoming null in the FindEditorData.java. -Caroline --- Richard Yee [EMAIL PROTECTED] wrote: Caroline, As a sanity check, in your bean, initialize the username variable to something ie. XX. and re-run your app. This will show if your setUsername is ever called. -Richard --- Caroline Jen [EMAIL PROTECTED] wrote: I do not fully understand what you say about null or null. Anyway, I did try to write out values in the FindEditorData.java. What is written out in the browser is: name=null; kn=journal_category; kv=null And the way I try to write out those crucial fields is shown below: // package and import statements omitted public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData --- Richard Yee [EMAIL PROTECTED] wrote: Caroline, In your FindEditorData.java class, is the value for your username variable null or null? If it is null, then you are reading the wrong request parameter since request.getParameter() will return null if the parameter doesn't exist. If the String value is null, then you have a problem with getRemoteUser() Why don't you dump request parameters that you are getting in your FindEditorData? Hidden input tags work fine. Regards, Richard --- Caroline Jen [EMAIL PROTECTED] wrote: Hi, I think that we are in different time zones. As you have mentioned, I, too, suspected that the statement in my JSP: request.getRemoteUser(); returns nothing. Therefore, I did a test in my JSP. In addition to request.getRemoteUser(); I created another String manually: req:isUserInRole role=editor % String username = request.getRemoteUser(); String userrole = author; % % out.println(The user name is: + username +.); % % out.println(The role is: + userrole +.); % /req:isUserInRole And the browser shows: The user name is: Gloria Jen. The role is: author. Gloria Jen is the name that I provided while logging on and authenticated by the container. Therefore, the request.getRemoteUser(); does not return a null. And I hope that it means I am not passing a null value when I use the hidden field technique. Then, I pass two hidden fields (with value in them) from my JSP to a Java class (FindEditorData.java), which is of scaffold.ProcessAction type. One of the field is passed with its value correctly retrieved. The other field is passed with its value found to be null. What could go wrong? I have been thinking about it for days and so do those who try to help me. req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser(); String userrole = author; % %out.println(The user name is: + username +.);% %out.println(The role is: + userrole +.);% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole -Caroline --- Yee, Richard K,,DMDCWEST [EMAIL PROTECTED] wrote: Caroline, Imposible? Look at the HTML that is generated by the JSP page. I think you will see that it returns null. Take a look at the JavaDoc for HttpServletRequest.getRemoteUser(); getRemoteUser public java.lang.String getRemoteUser() Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether
Re: HELP: about to get datasource of struts and pass to logic beans...
There are lots of classes involved. I will give you an example: 1. my LogonAction calls EditorService.java (business delegate) 2. EditorService.java calls MySQLEditorDAO.java (data access object implements EditorDAO.java, which is a data access interface) 3. the MySQLEditorDAO.java returns EditorBean.java (a Java bean with three properties) Here is my LogonAction.java: package org.apache.artimus.logon; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; import org.apache.artimus.lang.Tokens; public final class LogonAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws java.lang.Exception { // Obtain username and password from web tier String username = ((LogonForm) form).getUsername(); String password = ((LogonForm) form).getPassword(); EditorService service = new EditorService(); EditorBean editor = service.findEditorData( username ); HttpSession session = request.getSession(); session.setAttribute( editor, editor ); // Log this event, if appropriate if (servlet.getDebug() = Tokens.DEBUG) { StringBuffer message = new StringBuffer(LogonAction: User '); message.append(username); message.append(' logged on in session ); message.append(session.getId()); servlet.log(message.toString()); } // Return success return (mapping.findForward(Tokens.VALID)); } } // End LogonAction Here is the EditorService.java: package org.apache.artimus.logon; import org.apache.artimus.logon.dao.*; public class EditorService { EditorDAO ed = new MySQLEditorDAO(); public EditorBean findEditorData( String username ) { return ed.findEditor( username ); } } Here is the EditorDAO.java: package org.apache.artimus.logon.dao; import org.apache.artimus.logon.EditorBean; import org.apache.artimus.logon.exceptions.EditorDAOSysException; public interface EditorDAO.java { public EditorBean findEditor( String username ) throws EditorDAOSysException; } Here is the MySQLEditorDAO.java: package org.apache.artimus.logon.dao; import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.sql.SQLException; import org.apache.artimus.logon.EditorBean; import org.apache.artimus.logon.exceptions.EditorDAOSysException; import org.apache.artimus.ConnectionPool.DBConnection; public class MySQLEditorDAO implements EditorDAO { // Here the return type is EditorBean public EditorBean findEditor( String username ) throws EditorDAOSysException { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = DBConnection.getDBConnection(); stmt = conn.createStatement(); String query = SELECT user_role, journal_category FROM members WHERE user_name = ' + username + '; rs = stmt.executeQuery( query ); if (rs.next()) { return new EditorBean( username, rs.getString( user_role ), rs.getString( journal_category ) ); } else { System.out.println( invalid user name ); return null; } } catch (SQLException se) { throw new EditorDAOSysException(SQLException: + se.getMessage()); } finally { if ( conn != null ) { try { rs.close(); rs = null; stmt.close(); stmt = null; conn.close(); } catch( SQLException sqlEx ) { System.out.println( Problem occurs while closing + sqlEx ); } conn = null; } } } } Here is the EditorBean.java: package org.apache.artimus.logon; import org.apache.artimus.logon.dao.*; public class EditorBean { private String username; private String userrole; private String keyValue; static EditorDAO ed = new MySQLEditorDAO(); public EditorBean() {} public EditorBean( String username, String userrole, String keyValue ) { setUsername( username ); setUserrole( userrole ); setKeyValue( keyValue ); } public String getUsername() { return
Re: Please Help! Unable to Pass A Hidden Field To scaffold.ProcessAction
I did not mess up lowercase and uppercase of the hidden field I want to pass from my JSP to the scaffold.ProcessAction. If it had been the lowercase/uppercase problem, I would have gotten a message saying that the variable could not be recognized. I pass two hidden fields at the same time. One of them is successfully passed with correct value. The other is passed but its value shows a 'null' in the scaffold.ProcessAction. What could go wrong? Let me show my code again: Two hidden fields: username and keyName are passed from a JSP via a SUBMIT button: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole and an action mapping: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action The value of the 'username' is found to be a 'null' in the FindEditorData.java while the value of keyName is successfully retrieved. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData --- Caroline Jen [EMAIL PROTECTED] wrote: I want to pass two hidden fields; username and keyName from a JSP via a SUBMIT button: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole and an action mapping: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action How come the username is not passed to the FindEditorData.java while the keyName is successfully passed. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction
I pass two hidden fields: username and keyName at the same time. The keyName is passed and with the correct value in it. The username is passed but its value turns out to be a null. It is impossible for request.getRemoteUser(); in my JSP returning a null. (see code below) Before it reaches request.getRemoteUser(); the user has already been successfully logged in with a valid name. req:isUserInRole role=editor html:form action=/find/Category TR TD class=option % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /TD /TR /html:form /req:isUserInRole --- Yee, Richard K,,DMDCWEST [EMAIL PROTECTED] wrote: Caroline, Are you having problems with the username or the keyName hidden variable? If it is the username, then I'd suspect that request.getRemoteUser() in your JSP is returning null. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 1:32 PM To: Struts Users Mailing List Subject: Re: Please Help! Unable to Pass A Hidden Field To scaffold.ProcessAction I did not mess up lowercase and uppercase of the hidden field I want to pass from my JSP to the scaffold.ProcessAction. If it had been the lowercase/uppercase problem, I would have gotten a message saying that the variable could not be recognized. I pass two hidden fields at the same time. One of them is successfully passed with correct value. The other is passed but its value shows a 'null' in the scaffold.ProcessAction. What could go wrong? Let me show my code again: Two hidden fields: username and keyName are passed from a JSP via a SUBMIT button: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole and an action mapping: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action The value of the 'username' is found to be a 'null' in the FindEditorData.java while the value of keyName is successfully retrieved. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData --- Caroline Jen [EMAIL PROTECTED] wrote: I want to pass two hidden fields; username and keyName from a JSP via a SUBMIT button: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole and an action mapping: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action How come the username is not passed to the FindEditorData.java while the keyName is successfully passed. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService
RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction
I use container-managed authentication. --- Yee, Richard K,,DMDCWEST [EMAIL PROTECTED] wrote: Caroline, Imposible? Look at the HTML that is generated by the JSP page. I think you will see that it returns null. Take a look at the JavaDoc for HttpServletRequest.getRemoteUser(); getRemoteUser public java.lang.String getRemoteUser() Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER. Returns: a String specifying the login of the user making this request, or null As the JavaDoc says: Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Are you using basic authentication or are you authenticating the user yourself? If you are doing it yourself (ie. through a db lookup) then the server doesn't know about the user being authenticated and will return null. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 2:56 PM To: Struts Users Mailing List Subject: RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction I pass two hidden fields: username and keyName at the same time. The keyName is passed and with the correct value in it. The username is passed but its value turns out to be a null. It is impossible for request.getRemoteUser(); in my JSP returning a null. (see code below) Before it reaches request.getRemoteUser(); the user has already been successfully logged in with a valid name. req:isUserInRole role=editor html:form action=/find/Category TR TD class=option % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /TD /TR /html:form /req:isUserInRole --- Yee, Richard K,,DMDCWEST [EMAIL PROTECTED] wrote: Caroline, Are you having problems with the username or the keyName hidden variable? If it is the username, then I'd suspect that request.getRemoteUser() in your JSP is returning null. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 1:32 PM To: Struts Users Mailing List Subject: Re: Please Help! Unable to Pass A Hidden Field To scaffold.ProcessAction I did not mess up lowercase and uppercase of the hidden field I want to pass from my JSP to the scaffold.ProcessAction. If it had been the lowercase/uppercase problem, I would have gotten a message saying that the variable could not be recognized. I pass two hidden fields at the same time. One of them is successfully passed with correct value. The other is passed but its value shows a 'null' in the scaffold.ProcessAction. What could go wrong? Let me show my code again: Two hidden fields: username and keyName are passed from a JSP via a SUBMIT button: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole and an action mapping: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action The value of the 'username' is found to be a 'null' in the FindEditorData.java while the value of keyName is successfully retrieved. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase
Each Time the Server Restarts, the Browser Does Not Display the Welcome Page.
While the server is running, I am able to be redirected to the welcome page after I click on any of the LOGOUT buttons in my application. And while I am at the welcome page, I can see http://localhost:8080/NameOfMyApplication/do/Main in the address bar. But, if I shut down the server and restart it, the browser shows a page with all the images that I defined in the tile (I use tile to show web pages) and a LOGOUT button. In the address bar, I see http://localhost:8080/NameOfMyApplication/do/Main;jsessionid=49I943J0FJQIQ205058 I must click on that LOGOUT button in order to go to my welcome page. That is to say, I do not directly get the welcome page each time the server restarts. I must have messed something up and would appreciate if anybody could help identifying the problem. In my web.xml, I have: welcome-file-list welcome-fileindex.jsp/welcome-file /welcome-file-list and this index.jsp (shown below) is in my application root: %@ taglib uri=/tags/struts-logic prefix=logic % logic:redirect forward=welcome/ The mapping in the struts-config.xml is: forward name=welcome path=/do/Main/ I think the logout part would be more informative. The LOGOUT button is in a piece of tile: %@ taglib uri=/tags/struts-html prefix=html % /TABLE /TD /TR TRTDBR/TD/TR TR TD ALIGN=CENTER html:img page=/article/common/images/goldbrush.gif border=0 alt=[goldbrush]/ /TD /TR TRTDBR/TD/TR TR TD class=navbar html:link forward=exitLOGOUT/html:link /TD /TR /TABLE The mapping in the struts-config.xml is: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.apache.artimus.signoff.LogoffAction forward name=success redirect=true path=/index.jsp/ /action The code in the LogoffAction.java is shown below: // package and import statements are omitted public final class LogoffAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType( text/html ); PrintWriter out = response.getWriter(); // Extract attributes we will need HttpSession session = request.getSession( false ); if (session != null) { session.invalidate(); } return (mapping.findForward( success )); } } // end LogoffAction __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please Help! Unable to Pass A Hidden Field To scaffold.Proces sAction
I must pass the result of request.getRemoteUser() because it is a Java class that receives the hidden field. If you read my code carefully, you will see that FindEditorData.java is a Java class and I cannot use 'request' or 'session' in a Java class. It takes a servlet or a class extends Action to use 'request' or 'session'. But, this class is of ProcessAction type defined in the struts-config.xml: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action And, it is easy to see that I use container-managed authentication. In my JSP, there is req:isUserInRole role=editor before reaching % String username=request.getRemoteUser(); % Again, I have provided my code: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser(); % html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole --- Richard Yee [EMAIL PROTECTED] wrote: Caroline, Why are you passing the result of request.getRemoteUser() in a hidden variable anyway since it is available as part of the HttpRequest and thus will be available in the action class? -Richard At 02:55 PM 12/8/2003, you wrote: I pass two hidden fields: username and keyName at the same time. The keyName is passed and with the correct value in it. The username is passed but its value turns out to be a null. It is impossible for request.getRemoteUser(); in my JSP returning a null. (see code below) Before it reaches request.getRemoteUser(); the user has already been successfully logged in with a valid name. req:isUserInRole role=editor % String username = request.getRemoteUser();% value=journal_category/ value=%=username%/ View Articles --- Yee, Richard K,,DMDCWEST wrote: Caroline, Are you having problems with the username or the keyName hidden variable? If it is the username, then I'd suspect that request.getRemoteUser() in your JSP is returning null. Regards, Richard -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 1:32 PM To: Struts Users Mailing List Subject: Re: Please Help! Unable to Pass A Hidden Field To scaffold.ProcessActionI did not mess up lowercase and uppercase of the hidden field I want to pass from my JSP to the scaffold.ProcessAction. If it had been the lowercase/uppercase problem, I would have gotten a message saying that the variable could not be recognized. I pass two hidden fields at the same time. One of them is successfully passed with correct value. The other is passed but its value shows a 'null' in the scaffold.ProcessAction. What could go wrong? Let me show my code again: Two hidden fields: username and keyName are passed from a JSP via a SUBMIT button: % String username = request.getRemoteUser();% value=journal_category/ value=%=username%/ View Articles and an action mapping: roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false name=success path=.article.Result/The value of the 'username' is found to be a 'null' in the FindEditorData.java while the value of keyName is successfully retrieved. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData --- Caroline Jen wrote: I want to pass two hidden fields; username and keyName from a JSP via a SUBMIT button: % String username = request.getRemoteUser();% value=journal_category/ value=%=username%/ View Articles and an action mapping: roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction
Pass A String From Servlet And Write Out Its Value in JSP
My servlet has a String called 'category'. I want to pass the String to a JSP. Therefore, I have the code shown below in the servlet: session.setAttribute( c, category ); OR request.setAttribute( c, category ); And, I do the following in my JSP: % String keyValue = (String)session.getAttribute( c ); % OR % String keyValue = (String)request.getAttribute( c ); % How do I write out keyValue in my JSP in Struts? __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Please Help! Unable to Pass A Hidden Field To scaffold.ProcessAction
I want to pass two hidden fields; username and keyName from a JSP via a SUBMIT button: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole and an action mapping: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action How come the username is not passed to the FindEditorData.java while the keyName is successfully passed. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Please Help! Unable to Pass A Hidden Field To scaffold.ProcessAction
My code was shown in my original message. I used two html:hidden ... tags to pass two hidden fields, one is successfully passed while the other shows null. By the way, I do not use 'request' to retrieve the value of the hidden field because my Java class is a scaffold.ProcessAction type. I simply use getXxx. Let me show my code again: req:isUserInRole role=editor html:form action=/find/Category % String username = request.getRemoteUser();% html:hidden property=keyName value=journal_category/ html:hidden property=username value=%=username%/ html:submitView Articles/html:submit /html:form /req:isUserInRole --- Richard Yee [EMAIL PROTECTED] wrote: Are you using the input type=hidden or html:hidden attributes? I didn't see it in your email. If you do, the values will be available in the request. Regards, Richard At 08:20 PM 12/7/2003, you wrote: I want to pass two hidden fields; username and keyName from a JSP via a SUBMIT button: req:isUserInRole role=editor % String username = request.getRemoteUser();% value=journal_category/ value=%=username%/ View Articles and an action mapping: How come the username is not passed to the FindEditorData.java while the keyName is successfully passed. In the browser, I got: name=null; kn=journal_category; kv=null The code of my FindEditorData is shown below: public final class FindEditorData extends Bean { public Object execute() throws Exception { // Obtain username String username = getUsername(); EditorService service = new EditorService(); String value = service.findEditorData( username ); String property = getKeyName(); if (( null==property ) || ( null==value )) { StringBuffer sb = new StringBuffer(); sb.append( name= ); sb.append( username ); sb.append( ; kn= ); sb.append( property ); sb.append( ; kv= ); sb.append( value ); throw new ParameterException( sb.toString() ); } ResultList list = new ResultListBase ( Access.findByProperty( this,property,value ) ); list.setLegend( property,value ); return new ProcessResultBase( list ); } // end execute } // End FindEditorData __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Troubled in Finding Ways to Pass a Variable to a Class
I know how to pass a hidden field. The problem is how to retrieve it in my Java class. I have illustrated that my Java class does not extend HttpServlet or Action. This Java class has a mapping in the struts-config.xml file: type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm -Caroline --- Timo [EMAIL PROTECTED] wrote: Caroline, The best way I use it to pass parameters to the action class is via a hidden attribute in the form, in your case the articleForm you can define the hidden attribute using input type=hidden name=hiddenField value=%=request.getRemoteUser();%/ Good luck. - Original Message - From: Caroline Jen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 05, 2003 8:17 PM Subject: Very Troubled in Finding Ways to Pass a Variable to a Class I have a class FindEditorData.java. I want to pass a vairable 'username' to this class for some processing. This class is invoked from a JSP: html:form action=/find/Category html:submitView Articles/html:submit and the value of the 'username' is obtained this way: String username = request.getRemoteUser(); Due to my limited knowledge in Struts, I cannot figure out what to do. Let me explain the problem: 1. This class has this method: public Object execute() throws Exception { ... } I do not make this class extends HttpServlet or extends Action. I cannot nest a method inside a doGet/doPost or the Action's excute(). 2. The action mapping in the struts-config.xml is this way: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm validate=false forward name=success path=.article.Result/ /action I am stuck because I do not know how to pass 'username' to the FindEditorData.java. I cannot state: String username = request.getRemoteUser(); or String username = (String)session.getAttribute( EditorName ); because the FindEditorData is not a servlet and does not extend Action. I cannot pass a hidden variable from the JSP because I do not know how to retrieve the value of a hidden variable in a Java class. Need clever ideas. Please help. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Very Troubled in Finding Ways to Pass a Variable to a Class
It is wonderful to know that there are some ActionForm methods that holds true in the scaffold.ProcessAction's execute() method. It gives the hope that my problem could be resolved. Via a submit button in my JSP, I try to pass two variables; username and keyName, to my Java class (FindEditorData.java) with the type=org.apache.struts.scaffold.ProcessAction, and this Java class has this method: public Object execute() throws Exception { ... } 1. if I use the hidden field technique (see below) inside the JSP html:form tag: % String username = request.getRemoteUser();% html:hidden property=username value=%=username%/ html:hidden property=keyName value=journal_category/ How do I retrieve the value of username and keyName in the Java class? Probably due to my lack of knowledge of the ActionForm, I got compilation error cannot resolve symbol: request or cannot resolve symbol: session because FindEditorData.java does not extend HttpServlet and FindEditorData.java does not extend Action. 2. if I want to get 'username' in the Java class instead of passing the 'username' as a hidden field from a submit button in my JSP, how do I do it? String username = request.getRemoteUser(); gives me a compilation error cannot resolve symbol: request. The action mapping in my struts-config.xml looks like: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.FindEditorData name=articleForm scope=request validate=false forward name=success path=.article.Result/ /action -Caroline --- Joe Hertz [EMAIL PROTECTED] wrote: Actually, you haven't illustrated it. You've just stated it. In the ActionForm there are methods like validate() that accept as parameters an ActionMapping and an httpServletRequest, and from the httpServletRequest you can call getSession(). Same holds true in the Action class' execute() method. So what is the problem with your class? Why can't you utilize it from one of these places that you do have access to these things? What exactly is stopping you here? Once you tell us, then you will have illustrated the problem. -J -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Saturday, December 06, 2003 1:47 PM To: Struts Users Mailing List Subject: Re: Very Troubled in Finding Ways to Pass a Variable to a Class I know how to pass a hidden field. The problem is how to retrieve it in my Java class. I have illustrated that my Java class does not extend HttpServlet or Action. This Java class has a mapping in the struts-config.xml file: type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm -Caroline --- Timo [EMAIL PROTECTED] wrote: Caroline, The best way I use it to pass parameters to the action class is via a hidden attribute in the form, in your case the articleForm you can define the hidden attribute using input type=hidden name=hiddenField value=%=request.getRemoteUser();%/ Good luck. - Original Message - From: Caroline Jen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 05, 2003 8:17 PM Subject: Very Troubled in Finding Ways to Pass a Variable to a Class I have a class FindEditorData.java. I want to pass a vairable 'username' to this class for some processing. This class is invoked from a JSP: html:form action=/find/Category html:submitView Articles/html:submit and the value of the 'username' is obtained this way: String username = request.getRemoteUser(); Due to my limited knowledge in Struts, I cannot figure out what to do. Let me explain the problem: 1. This class has this method: public Object execute() throws Exception { ... } I do not make this class extends HttpServlet or extends Action. I cannot nest a method inside a doGet/doPost or the Action's excute(). 2. The action mapping in the struts-config.xml is this way: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm validate=false forward name=success path=.article.Result/ /action I am stuck because I do not know how to pass 'username' to the FindEditorData.java. I cannot state: String username = request.getRemoteUser(); or String username = (String)session.getAttribute( EditorName ); because the FindEditorData is not a servlet and does not extend Action. I cannot pass a hidden
Mail Messages Using JavaMail in Struts
Has a Struts application been built to handle send/view personal mail messages using JavaMail? If the answer is yes, please provide information how to contact the developer of the application. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Very Troubled in Finding Ways to Pass a Variable to a Class
I have a class FindEditorData.java. I want to pass a vairable 'username' to this class for some processing. This class is invoked from a JSP: html:form action=/find/Category html:submitView Articles/html:submit and the value of the 'username' is obtained this way: String username = request.getRemoteUser(); Due to my limited knowledge in Struts, I cannot figure out what to do. Let me explain the problem: 1. This class has this method: public Object execute() throws Exception { ... } I do not make this class extends HttpServlet or extends Action. I cannot nest a method inside a doGet/doPost or the Action's excute(). 2. The action mapping in the struts-config.xml is this way: action roles=editor path=/find/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.XYZ.article.FindEditorData name=articleForm validate=false forward name=success path=.article.Result/ /action I am stuck because I do not know how to pass 'username' to the FindEditorData.java. I cannot state: String username = request.getRemoteUser(); or String username = (String)session.getAttribute( EditorName ); because the FindEditorData is not a servlet and does not extend Action. I cannot pass a hidden variable from the JSP because I do not know how to retrieve the value of a hidden variable in a Java class. Need clever ideas. Please help. __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Please Give Me A Clue - ClassCast Exception
My application got a ClassCastException at scaffold, ProcessAction.executeLogic. I have no idea about how and where to detect the problem. I would appreciate if someone could provide a clue. 2003-12-04 23:08:38 action: *** ACTION EXCEPTION: java.lang.ClassCastException at org.apache.struts.scaffold.ProcessAction.executeLogic(Unknown Source) at org.apache.struts.scaffold.BaseHelperAction.executeLogic(Unknown Source) at org.apache.struts.scaffold.BaseAction.execute(Unknown Source) __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Drop-Down List - Cannot Retrieve Definition From Form Bean Null
My drop-down list got an error message: org.apache.jasper.JasperException: Cannot retrieve definition for form bean null I have tried to display the drop-down list in two ways: First: html:select size=1 property=editor multiple=false html:options collection=editors property=name labelProperty=name/ /html:select Second: bean:define id=editorsList name=editors scope=session / html:select property=editor size=1 multiple=false html:options collection=editorsList labelProperty=name property=value/ /html:select The editors is a Collection of EditorBean passed to the JSP this way: HttpSession session = request.getSession(); session.setAttribute( editors, editors ); and Editor Bean is: public class EditorBean { private String name; public EditorBean() {} public EditorBean( String name ) { this.name = name; } public String getName() { return name; } public void setName( String name ) { this.name = name; } } __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How Do I Create This Drop-Down List in Struts?
My ArrayList is a collection of bean object. The ArrayList is created this way: public Collection findEditors( String userrole, String category ) { .. EditorBean editorBean = null; ArrayList editors = new ArrayList(); // database access code while( rs.next() ) { editorBean = new EditorBean( rs.getString(user_name) ); editors.add( editorBean ); } return editors; ... } and my EditorBean is like: public class EditorBean { private String name; public EditorBean() {} public EditorBean( String name ) { this.name = name; } public String getName() { return Name; } public void setName( String name ) { this.name = name; } } After editors is returned, I create a session object: session.setAttribute( EDITORS, editors ); How do I create a drop-down list for this collection of editors? html:select size=1 property=?? multiple=false html:options collection=?? property=name labelProperty=name/ /html:select __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
re: Getting ArrayList of objects from my form bean into my drop down list - solution
What a good timing to see this post. I was about to do the same thing in the next day or two. I have an ArrayList of JavaBean objects created from accessing the database: while(rs.next()) { editorBean=new EditorBean(rs.getString(user_name)); editors.add(editorBean); } return editors; Obviously, each EditorBean object is the value of the user_name. If I have this request.setAttribute( EDITORS, editors ); How do I create a drop-down list? Please comment the way I tend to code: html:select property=editors multiple=false bean:define id=EDITORS name=?? property=editors/ html:options collection=EDITORS property=? labelProperty=??/ /html:select What should I do with those places I marked with the question marks (?) --- Janice [EMAIL PROTECTED] wrote: Just in case some other newbies are doing the same thing, this was my solution: html:select property=projCodeName bean:define id=codes name=projectForm property=projCodeNames/ html:options collection=codes property=name labelProperty=name/ /html:select Its making a new bean on the .jsp page with my ArrayList that was in my form bean, and then I can easily get the values from it. (I can't wait until this stuff is all second nature! I haven't even started doing anything difficult yet!) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How To Display the Information That Is Wrapped In a Session Object
1. I my action class, I reference a bean EditorBean editor = EditorBean.findEditorData( username ); 2. this bean accesses the data access logic and the bean gets populated by information fetched from the database (see the code below) 3. In the action class, I then wrap editor in a session object: HttpSession session = request.getSession(); editor.setUserrole( request.getParameter( userrole ) ); editor.setCategory( request.getParameter( category ) ); session.setAttribute( editor, editor ); 4. In the JSP, how do I get userrole and category from the session object and how to display them in Struts? Here is my EditorBean class: public class EditorBean { private String username; private String userrole; private String category; // UserDAO and MySQLUserDAO are in another package. Must import that package. // should not instantiate an interface because it does not have a constructor static EditorDAO ed = new MySQLEditorDAO(); public EditorBean() {} public EditorBean( String username, String userrole, String category ) { setUsername( username ); setUserrole( userrole ); setCategory( category ); } public String getUsername() { return username; } public void setUsername( String username ) { this.username = username; } public String getUserrole() { return userrole; } public void setUserrole( String userrole ) { this.userrole = userrole; } public String getcategory() { return category; } public void setCategory( String category ) { this.category = category; } public static EditorBean findEditorData( String username ) { return ed.findEditor( username ); } } __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Off Topic, Problem With Passing Business Bean in Between Classes As Part of My Struts Application
It is not a Struts problem. But, it is the problem I encounter in my Struts application. Please help. I am NOT showing all my code. For example, I skip the DAO interface, and the class that returns a connection object from the connection pool. Nonetheless, those classes are irrelevant to my question. The root of my problem is that I do not know how to pass data that are wrapped in a business bean in between classes. THE JAVA COMPILER DOES NOT RECOGNIZE THE BUSINESS BEAN! 1. I have a controller Servlet that reads the username that is supplied by a visitor of the web site. I want to search the database by the username and get some information about that user; such as userrole, category, etc. A business bean sits in between the controller servlet and the database. Here is the partial code of the controller servlet: [code] // the statement below has problems EditorBean editorData; // Obtain username and password from web tier String username = request.getParameter( username ); // find the editor's information via the business tier // Again, the parameters that I supplied in the method below have problems EditorBean editor = EditorBean.findEditorData( username, editorData ); // wrap the information found in the database in a session object and go on HttpSession session = request.getSession(); editor.setUserrole( request.getParameter( userrole ) ); editor.setCategory( request.getParameter( category ) ); session.setAttribute( editor, editor ); [/code] 2. I have this EditorBean class. This EditorBean is a business bean. I am struggling with how the EditorBean pass the data in between the controller and the database. [code] import org.apache.artimus.logon.dao.*; public class EditorBean { private String username; private String userrole; private String category; EditorDAO ed = new MySQLEditorDAO(); public EditorBean() {} public EditorBean( String username, String userrole, String category ) { setUsername( username ); setUserrole( userrole ); setCategory( category ); } public String getUsername(){ return username; } public void setUsername( String username ) { this.username = username; } public String getUserrole(){ return userrole; } public void setUserrole( String userrole ) { this.userrole = userrole; } public String getcategory(){ return category; } public void setCategory( String category ) { this.category = category; } // the parameters in the method below have problems public EditorBean findEditorData( String username, EditorBean editorData ) { // What do I do here? ed.findEditor( String username, ?? ); // I am not sure what to return here return ?; } } [/code] 3. Here is my data access class: [code] import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.sql.SQLException; import org.apache.artimus.logon.exceptions.EditorDAOSysException; import org.apache.artimus.ConnectionPool.DBConnection; public class MySQLEditorDAO implements EditorDAO{ // the parameters of the method below have problems public EditorBean findEditor( String username, ?? ) throws EditorDAOSysException { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = DBConnection.getDBConnection(); stmt = conn.createStatement(); String query = SELECT user_role, journal_category FROM members WHERE user_name = ' + username + '; rs = stmt.executeQuery( query ); if (rs.next()) { // something is wrong in returning the information about that editor return new EditorBean( username, rs.getString( user_role ), rs.getString( journal_category) ); } else { System.out.println( invalid user name ); return null; } } catch (SQLException se) { throw new EditorDAOSysException(SQLException: + se.getMessage()); } finally { if ( conn != null ) { try { rs.close(); rs = null; stmt.close(); stmt = null; conn.close(); } catch( SQLException sqlEx ) { System.out.println( Problem occurs while closing + sqlEx ); } conn = null; } } } } [/code] __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FAQ (Passing Variables Between Actions); But, Stuck and Need Help
Passing variables from one action to another is a frequently asked question. The answer is to use either hidden fields or a session object. The story starts with searching the database. My application offers options to search the database by author, title of the article, article ID, or . I have a drop-down list in my JSP for visitors to make a selection. By clicking on one of those options, the property dispatch is set. And the visitor fills out the text field to set keyValue. With both dispatch and keyValue forwarded to an action; say, Action ONE, the desired articles can be retrieved from the database. So far so good. What I have handled next is the author's page of the web site. An author can only view his own articles and perform update, delete, save, ... functions. I use the hidden field technique to handle it. The property dispatch is arbitrarily set as author (needless to say) and keyValue can be obtained by String username = request.getRemoteUser(); And, html:hidden property=dispatch value=author/ html:hidden property=keyValue value=%=username%/ are forwarded to the same action (Action ONE) for processing. Again, no problem. Now, the application has another user case - editors. An editor only retrieve and view all articles in his/her own field of specialization. I arbitrarily set dispatch as field_of_specialization and use the hidden field technique: html:hidden property=dispatch value=field_of_Specialization/ Nonetheless, the way to get the value the editor's field of specialization is from the database. Because editors are registered members of the web site, the application should be able to look for his/her profile and obtain his/her field of specialization in the database once an editor successfully logs into the web site. Therefore, it takes an action (Action TWO) that tells the business tier to find the keyValue in the database. And should I put the keyValue in a session object. I have tried to handle this situation again and again in many different ways. I am very frustrated and need help -- how does a user go from by clicking a button in a JSP to go to Action TWO (get the keyValue) and then forward this keyValue and html:hidden property=dispatch value=field_of_Specialization/ to Action ONE for retrieving the desired articles from the database? __ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FAQ (Passing Variables Between Actions); But, Stuck and Need Help
Thank you for the very useful and constructive feedbacks. I think I am going for the first method that you suggested - create a user bean and store it in a session object at login. My concern is that I use container managed authentication at login. After the container does its job, is there any way other than using an Action that delegates the business tier to search the database and obtain the value of field_of_specialization? If an action has to be involved at this point to form a session object, does it suffer the the disadvantage of being overwritten if the user has more than one browser window opened? In regard to the two-action approach that you discussed toward the end of your message, I encountered some problems. If you would take a look at the problem - I provide a buttion in editor's page, which is a JSP tile: req:isUserInRole role=editor html:form action=/do/editor/Category html:submitView Articles/html:submit /html:form /req:isUserInRole If the button is clicked, I attempt to use an Action (via the path /editor/Category) to search the database for the field_of_specialization. However, I got this message in the browser: [ServletException in:/article/content/menu.jsp] Cannot retrieve mapping for action /do/editor/Category' and in my struts-config.xml action path=/editor/Category type=org.apache.artimus.article.EditorViewAction forward name=success path=/menu/Find/ /action -Caroline --- Adam Hardy [EMAIL PROTECTED] wrote: On 11/06/2003 08:26 AM Caroline Jen wrote: Passing variables from one action to another is a frequently asked question. The answer is to use either hidden fields or a session object. [snip...] Now, the application has another user case - editors. An editor only retrieve and view all articles in his/her own field of specialization. I arbitrarily set dispatch as field_of_specialization and use the hidden field technique: html:hidden property=dispatch value=field_of_Specialization/ Nonetheless, the way to get the value the editor's field of specialization is from the database. Because editors are registered members of the web site, the application should be able to look for his/her profile and obtain his/her field of specialization in the database once an editor successfully logs into the web site. Therefore, it takes an action (Action TWO) that tells the business tier to find the keyValue in the database. And should I put the keyValue in a session object. One method that I use is to create a user bean and store that in the session at login. This bean could include your editor's field of specialization, so that you don't need an extra action. Secondly, you could drop the Action One by incorporating the field of specialization as a part of one SQL statement, so that you never actually extract the field of specialization from the DB. I.e. something like this: SELECT article_title, article_text FROM app_user, article WHERE app_user.user_name = ? AND app_user.field_of_specialization = article.field_of_specialization Alternatively if you still want to do 2 actions, I have seen people handle it in various ways: (1) get the action-forward in your action and modify the path to add a query_string with your keyValue on it (2) put the keyValue in a cookie (3) as you said, put it in the session. 2 3 have the disadvantage that they could be overwritten if the user has more than one browser window open. HTH Adam -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Why the Action Mapping Cannot Be Retrieved?
I got this message in the browser: [ServletException in:/article/content/menu.jsp] Cannot retrieve mapping for action /do/editor/Category' The menu.jsp is a tile in my application. This is my tile menu.jsp: req:isUserInRole role=editor html:form action=/do/editor/Category TR TD class=option html:submit style=font: 10pt sans-serif White; background:Teal; width:130px; height:30pxView Articles/html:submit /TD /TR /html:form /req:isUserInRole If I change the statement that causes the ServletException to html:form action=editor/Category I got [ServletException in:/article/content/menu.jsp] Cannot retrieve definition for form bean null' However, I have no problem if menu.jsp is like: req:isUserInRole role=editor html:form action=/menu/Find TR TD class=option html:submit style=font: 10pt sans-serif White; background:Teal; width:130px; height:30pxView Articles/html:submit /TD /TR /html:form /req:isUserInRole The /menu/Find in my struts-config.xml is action path=/menu/Find type=org.apache.struts.scaffold.ParameterAction name=menuForm validate=false parameter=keyValue forward name=title path=/do/find/Property?keyName=titleamp;keyValue=/ forward name=author path=/do/find/Property?keyName=creatoramp;keyValue=/ forward name=journal_category path=/do/find/Property?keyName=journal_categoryamp;keyValue=/ forward name=content path=/do/find/Property?keyName=contentamp;keyValue=/ forward name=article path=/do/article/View?article=/ /action And, /editor/Category in my struts-config.xml is like: action path=/editor/Category type=org.apache.struts.scaffold.ProcessAction parameter=org.apache.artimus.article.EditorViewAction forward name=success path=/menu/Find/ /action __ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Handling Session Timeout
People have suggested servlet filter is a good choice to check session time-out that if I want all servlets and JSPs remain intact. I do not have any idea how it works in Struts. First of all, I think this servlet filter has to be declared in the web.xml. I have many actions in the struts application. How do I call this servlet filter whenever the flow goes to an action? Do I code HttpSession session = request.getSession( false ); if ( session != null) { session.removeAttribut( ... ); session.invalidate(); } in the doFilter(); ? --- Seyhan BASMACI (Internet Yazilimlari Yetkilisi) [EMAIL PROTECTED] wrote: try this :) public class SessionRequestProcessor extends TilesRequestProcessor{ protected String processPath(HttpServletRequest request, HttpServletResponse response) throws IOException { String origPath = request.getRequestURI(); if(!origPath.endsWith(/Login.do)){ HttpSession session = request.getSession(false); // get session only if it exists if (session != null ) {// session available, return super.processPath(request, response); } else// redirect to login page return /Login; // returns without .do } else { HttpSession session = request.getSession(false); // get session only if it exists if (session != null) session.invalidate(); return super.processPath(request, response); // process login page request } } -Original Message- From: Samanth Athrey [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 5:26 PM To: [EMAIL PROTECTED] Subject: Handling Session Timeout Hello Gurus I am trying to handle session timeout by extending RequestProcessor. Since the processPreprocess(...) method is called before the Action.execute(..) method, am trying to add that piece of code to check if the session is valid. The problem am facing is, if i return false from this method, the requestProcessor will stop processing and return the control back to doGet or doPost method in ActionServlet. How do I redirect it to login.jsp or index.jsp from there? Any help/tips would be really great. Thanx. Sam - 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] __ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Session Times Out
I check if session expires for each action in the application. If the session times out, I forward the user to index.jsp so that the user can log on again. How do I inform the user with a message that he/she is at the welcome page because the session has expired? __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: findByProperty() in the scaffold.sql.AccessBase - Need One Additional Parameter to the Pair of Property/Value
Please help. Need your clever ideas. Thank you. --- Caroline Jen [EMAIL PROTECTED] wrote: I am using the findByProperty method in the org.apache.commons.scaffold.sql.AccessBase. The findByProperty method takes one pair of property/value as it parameters. As such, visitors of the web site can query all articles in the database by providing 'author' as the property and supply the name of the author (xyz) as value. public static final Collection findByProperty ( Object target, String property, String value ) throws ParameterException, PopulateException, ResourceException I have this field category in my database. I want to search and get all the articles written by author(property) with name xyz (value) within the HISTORY category. The value of the category will be supplied by the application developer (NOT BY THE VISITOR of the web site via selecting from a drop-down list and fill out the value in the text field). I need help in handling this kind of situation. Thanks in advance. -Caroline __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Buttons in Struts
We have html:submit for the submit buttion in struts. I am trying to add some additional features to the submit button: BUTTON TYPE=submit NAME=submit VALUE=submit STYLE=font: 10pt Arial Black; background:Teal width:75px; height:25pxRead/Send Mails/BUTTON I wonder if there is something like it in struts. __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How To Submit A Propery/Value Pair That Is Not Selected/Filled-Out By Visitors of the Website?
In the welcome page, all visitors of the web site can choose to view any article that is available in the database. But, visitors will not be able to delete or update any of those articles (DELETE, UPDATE, etc. buttons are not provided). This part of my struts application works well. I have a drop-down list enclosed in html:form for visitors to make a selection and submit it for an action to be taken: html:form action=/menu/Find TR TD class=label nowrapFind articles by: /TD TD class=input html:select size=1 property=dispatch onchange=document.forms[1].elements[2].focus() html:options collection=FIND property=value labelProperty=label/ /html:select html:text property=keyValue size=20 maxlength=50/ /TD TDhtml:submitGO/html:submit/TD /TR /html:form Visitor can choose articles by title, author, category, content, or article ID. If author is selected from the drop-down list and the name of the author Victor Hugo is supplied, keyName will be set as creator and keyValue will be set as Victor Hugo for further processing as shown in my struts-config.xml below: action path=/menu/Find type=org.apache.struts.scaffold.ParameterAction name=menuForm validate=false parameter=keyValue forward name=title path=/do/find/Property?keyName=titleamp;keyValue=/ forward name=author path=/do/find/Property?keyName=creatoramp;keyValue=/ forward name=journal_category path=/do/find/Property?keyName=journal_categoryamp;keyValue=/ forward name=content path=/do/find/Property?keyName=contentamp;keyValue=/ forward name=article path=/do/article/View?article=/ /action After a registered visitor successfully logs in, a user specific page is displayed. For example, after the author Victor Hugo who has submitted several of his articles at the web site logs in, he will see a page with Submit Article and View Article (IT IS A LINK OR A BUTTON. IT IS NOT A DROP DOWN LIST), etc. The author can view his own articles only because DELETE, UPDATE, etc. buttons will be provided. I am stuck here. There is no drop-down list for Victor Hugo. How do I supply keyName (which is creator) and keyValue (request.getRemoteUser) to the action below if Victor Hugo clicks on the View Article button? action path=/menu/Find parameter=keyValue forward name=author path=/do/find/Property?keyName=creatoramp;keyValue=/ /action __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
findByProperty() in the scaffold.sql.AccessBase - Need One Additional Parameter to the Pair of Property/Value
I am using the findByProperty method in the org.apache.commons.scaffold.sql.AccessBase. The findByProperty method takes one pair of property/value as it parameters. As such, visitors of the web site can query all articles in the database by providing 'author' as the property and supply the name of the author (xyz) as value. public static final Collection findByProperty ( Object target, String property, String value ) throws ParameterException, PopulateException, ResourceException I have this field category in my database. I want to search and get all the articles written by author(property) with name xyz (value) within the HISTORY category. The value of the category will be supplied by the application developer (NOT BY THE VISITOR of the web site via selecting from a drop-down list and fill out the value in the text field). I need help in handling this kind of situation. Thanks in advance. -Caroline __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Modifying the ParameterAction Class in the org.apache.struts.scaffold
I am trying to modify the behavior of the ParameterAction.java in the org.apache.struts.scaffold to tailor it to my specific need. I put the struts.jar and struts-scaffold.jar in my classpath while compiling the sub-class. Nonetheless, I got cannot resolve symbol symbol: class ParameterAction Here is my AuthorParameterAction that extends ParameterAction: package org.apache.artimus.article; import java.io.IOException; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.scaffold.lang.Tokens; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; public class AuthorParameterAction extends ParameterAction { protected ActionForward findSuccess( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { // Get dispatch parameter String parameter = request.getParameter(Tokens.DISPATCH); // Get stub URI from mapping (/do/whatever?paramName=) StringBuffer path = new StringBuffer(64); path.append(mapping.findForward(parameter).getPath()); // Append the value passed (/do/whatever?paramName=paramProperty) path.append(request.getRemoteUser()); // Return a new forward based on stub+value return new ActionForward(path.toString()); } } // end AuthorParameterAction __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hidden Field
html:hidden property=dispatch value=author/ works well because author is expected literally as the value of a property called dispatch. I also want to pass String username = request.getRemoteUser(); as the value of a property called keyValue. But, html:hidden property=keyValue value=username/ or html:hidden property=keyValue value=username/ gives me problems. What is the proper way of doing it? __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
isUerInRole and request.tld
I have checked the syntax of the isUserInRole in the request.tld, which is: req:isUserInRole role=administrator %-- do something --% /req:isUserInRole Is it possible to specify more than one role? What is the syntax of specifying that? My application has many roles. In some cases, both administrator and say, contributor share doing the same thing. __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Forward Cannot Be Achieved In One Step
Hi, I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forward Cannot Be Achieved In One Step
The do/Menu does display my welcome page. The LOGOUT button and forward does eventually lead the visitor to the welcome page. The problem is that it takes two steps intead of going straight to the welcome page. Let me re-state my problem: I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? --- Ruth, Brice [EMAIL PROTECTED] wrote: Is your Menu actionforward the welcome screen you want to get to? And does your Action return an ActionForward to this? Caroline Jen wrote: Hi, I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Brice D. Ruth Sr. IT Analyst Fiskars Brands, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Forward Cannot Be Achieved In One Step
Thanks for the reply. Now, I understand that I have two actions. However, I do quite understand what you suggested. You said: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link I still have two actions if I use html:link action=/do/Logofflogoff/html:link because I have action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. --- [EMAIL PROTECTED] wrote: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link hence it wont be a 2 step stuff but directly calling ur Action class which does cleanup work for the log off process as session cleaning up and invalidating the other objects (probably signing off the user), And forwards later on to one of the jsp's U can create a global forward for the same too which represents an action. I guess its only available in 1.1 version of Struts. -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: 28 October 2003 17:05 To: Struts Users Mailing List Subject: Re: Forward Cannot Be Achieved In One Step The do/Menu does display my welcome page. The LOGOUT button and forward does eventually lead the visitor to the welcome page. The problem is that it takes two steps intead of going straight to the welcome page. Let me re-state my problem: I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? --- Ruth, Brice [EMAIL PROTECTED] wrote: Is your Menu actionforward the welcome screen you want to get to? And does your Action return an ActionForward to this? Caroline Jen wrote: Hi, I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Brice D. Ruth Sr. IT Analyst Fiskars Brands, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL
RE: Forward Cannot Be Achieved In One Step
Let me re-phrase my question. Upon the user click on the LOGOUT buttion, I have two actions - the first one of the actions is Logoff.java in which I invalidate the session, ..., etc. and the second action upon success will lead the user to the welcome page in which choices for unregistered member plus a LOGON buttion is provided. As long as two actions are involved, the user does not get back to the welcome page by just click on the LOGOFF button only once. Need your guidance on how such a situation is usually handled? --- Caroline Jen [EMAIL PROTECTED] wrote: Thanks for the reply. Now, I understand that I have two actions. However, I do quite understand what you suggested. You said: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link I still have two actions if I use html:link action=/do/Logofflogoff/html:link because I have action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. --- [EMAIL PROTECTED] wrote: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link hence it wont be a 2 step stuff but directly calling ur Action class which does cleanup work for the log off process as session cleaning up and invalidating the other objects (probably signing off the user), And forwards later on to one of the jsp's U can create a global forward for the same too which represents an action. I guess its only available in 1.1 version of Struts. -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: 28 October 2003 17:05 To: Struts Users Mailing List Subject: Re: Forward Cannot Be Achieved In One Step The do/Menu does display my welcome page. The LOGOUT button and forward does eventually lead the visitor to the welcome page. The problem is that it takes two steps intead of going straight to the welcome page. Let me re-state my problem: I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? --- Ruth, Brice [EMAIL PROTECTED] wrote: Is your Menu actionforward the welcome screen you want to get to? And does your Action return an ActionForward to this? Caroline Jen wrote: Hi, I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? __ Do you Yahoo!? === message truncated
RE: Forward Cannot Be Achieved In One Step
I have tried your suggestion. It still takes two steps to go back to the welcome page. As long as there are two actions in between, it does not seem that I can go directly from clicking the LOGOUT buttion to have the welcome page displayed. I really wish to learn what people usually do - the first one of those two actions is Logoff.java in which I invalidate the session, ..., etc. and the second action upon success will lead the user to the welcome page in which choices available for unregistered members plus a LOGON buttion are provided. -Caroline --- Yansheng Lin [EMAIL PROTECTED] wrote: At the end of your first action execute() method, do a redirect to the second action. Something like the following: return new ActionForward(secondAction.do); Hope this helps! -Yan -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: October 28, 2003 2:51 PM To: Struts Users Mailing List Subject: RE: Forward Cannot Be Achieved In One Step Let me re-phrase my question. Upon the user click on the LOGOUT buttion, I have two actions - the first one of the actions is Logoff.java in which I invalidate the session, ..., etc. and the second action upon success will lead the user to the welcome page in which choices for unregistered member plus a LOGON buttion is provided. As long as two actions are involved, the user does not get back to the welcome page by just click on the LOGOFF button only once. Need your guidance on how such a situation is usually handled? --- Caroline Jen [EMAIL PROTECTED] wrote: Thanks for the reply. Now, I understand that I have two actions. However, I do quite understand what you suggested. You said: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link I still have two actions if I use html:link action=/do/Logofflogoff/html:link because I have action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. --- [EMAIL PROTECTED] wrote: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link hence it wont be a 2 step stuff but directly calling ur Action class which does cleanup work for the log off process as session cleaning up and invalidating the other objects (probably signing off the user), And forwards later on to one of the jsp's U can create a global forward for the same too which represents an action. I guess its only available in 1.1 version of Struts. -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: 28 October 2003 17:05 To: Struts Users Mailing List Subject: Re: Forward Cannot Be Achieved In One Step The do/Menu does display my welcome page. The LOGOUT button and forward does eventually lead the visitor to the welcome page. The problem is that it takes two steps intead of going straight to the welcome page. Let me re-state my problem: I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? --- Ruth, Brice [EMAIL PROTECTED] wrote
Re: Forward Cannot Be Achieved In One Step
Excellent! It is the way to do it. Thank you for your guidance. It is very dumb of me not to think of it. --- Barry Volpe [EMAIL PROTECTED] wrote: I go directly to the welcome page this way: struts-config: action path=/Logoff type=com.childrencare.LogoffAction forward name=success path=/index.jsp/ /action In action: public final class LogoffAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Extract attributes we will need HttpSession session = request.getSession(); String user = (String) session.getAttribute(Constants.USER_KEY); // Remove user login session.removeAttribute(Constants.USER_KEY); // Return success return (mapping.findForward(Constants.SUCCESS)); Barry - Original Message - From: Caroline Jen [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, October 28, 2003 6:02 PM Subject: RE: Forward Cannot Be Achieved In One Step I have tried your suggestion. It still takes two steps to go back to the welcome page. As long as there are two actions in between, it does not seem that I can go directly from clicking the LOGOUT buttion to have the welcome page displayed. I really wish to learn what people usually do - the first one of those two actions is Logoff.java in which I invalidate the session, ..., etc. and the second action upon success will lead the user to the welcome page in which choices available for unregistered members plus a LOGON buttion are provided. -Caroline --- Yansheng Lin [EMAIL PROTECTED] wrote: At the end of your first action execute() method, do a redirect to the second action. Something like the following: return new ActionForward(secondAction.do); Hope this helps! -Yan -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: October 28, 2003 2:51 PM To: Struts Users Mailing List Subject: RE: Forward Cannot Be Achieved In One Step Let me re-phrase my question. Upon the user click on the LOGOUT buttion, I have two actions - the first one of the actions is Logoff.java in which I invalidate the session, ..., etc. and the second action upon success will lead the user to the welcome page in which choices for unregistered member plus a LOGON buttion is provided. As long as two actions are involved, the user does not get back to the welcome page by just click on the LOGOFF button only once. Need your guidance on how such a situation is usually handled? --- Caroline Jen [EMAIL PROTECTED] wrote: Thanks for the reply. Now, I understand that I have two actions. However, I do quite understand what you suggested. You said: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link I still have two actions if I use html:link action=/do/Logofflogoff/html:link because I have action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. And action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ The .article.Menu is my tile that displays the welcome page. --- [EMAIL PROTECTED] wrote: u can also use html:link action=/Logofflogoff/html:link where logoff is ur global forward. html:link forward=/Logofflogoff/html:link hence it wont be a 2 step stuff but directly calling ur Action class which does cleanup work for the === message truncated === __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
My logic Tag Does Not Seem To Work
Please point out my mistakes. Does the 'name' attribute of the logic tag accept an object only? For example, I created a session this way: HttpSession session = request.getSession(); String username = request.getRemoteUser(); session.setAttribute( user, username ); In the LogoffAction, I invalidate the session and want to forward the visitor to the welcome page. This is what I did: HttpSession session = request.getSession(false); String username = (String)session.getAttribute( user ); if (username != null) { session.removeAttribute( user ); session.invalidate(); return (mapping.findForward( success )); } I used the logic tag in my welcome.jsp. It does seem to work because the LOGOFF button is still displayed. logic:notPresent name=user html:link forward=logonLOGON/html:link /logic:notPresent logic:present name=user| html:link forward=exitLOGOUT/html:link /logic:present -Caroline __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Why the Forward Does Not Achieve In One Step?
Hi, I have the following code in the navbarMenu.jsp: html:link forward=exitLOGOUT/html:link and in the struts-config.xml, I have: forward name=exit path=/do/Logoff/ and action path=/Logoff type=org.NameOfOrganization.signoff.LogoffAction forward name=success path=/do/Menu/ /action In the LogoffAction.java, I invalidate the session and I want the user to go back the welcome page. The problem is that it takes two steps for the user to go back to the welcome page - After the first click, the same screen remains in the browser. The only change is what is shown in the address bar. I have to click the LOGOFF button again and then the welcome page is displayed. What should I do to go back to the welcome page in one step? __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tiles And Images
Hi, everybody. I have my problem solved. The images should be relative to the application root (it is where my mistake was). Nonetheless, if you do not mind, why it does not work at all when I tried to put image in the style sheet: td.bar { background: url('http://localhost:8080/PracticeVersion/article/assets/styles/images/goldbrush.gif'); } and I did the following in my JSP: TD class=bar/TD --- Ruth, Brice [EMAIL PROTECTED] wrote: Just an FYI (and correct me if I'm wrong), but just doing html:base/ will pretty much do what all the stuff you have below there does - what you have in there is the default behavior of the Struts-HTML base tag. Holman, Cal wrote: Try searching the archives this is a common issue. The requests for images are based on where the template tiles is using is located - not the location of the jsp being inserted in the template. One approach is to use the base tag - I do the following to ensure all images and links are rooted at the same level in the application - the root. This is the simplest, but there are other suggestions as well. This line is in the base template - or any template. base href=http://%= request.getServerName()%:%= request.getServerPort()%%=request.getContextPath()%/ Images then are referenced from the root of the web app - this is from the footer jsp img src=web/images/footer/struts-power.gif width=95 height=37 border=0 alt=struts/ My directory structure is App -- web (web stuff) --WEB-INF Others like the WEB-INF capability to protect resources. Cal http://www.calandva.com/Last update 08/01/03 -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Friday, October 24, 2003 14:42 To: [EMAIL PROTECTED] Subject: Tiles And Images I use tiles and stylesheet to display my web pages. I also try to insert some images in those pages. The tiles work fine. I have header, footer, navbar, content, etc. displayed without problem. But, I am curious to know if anybody has had difficulties in inserting images. I have tried various ways and cannot succeed. __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Learn more about Paymentech's payment processing services at www.paymentech.com THIS MESSAGE IS CONFIDENTIAL. This e-mail message and any attachments are proprietary and confidential information intended only for the use of the recipient(s) named above. If you are not the intended recipient, you may not print, distribute, or copy this message or any attachments. If you have received this communication in error, please notify the sender by return e-mail and delete this message and any attachments from your computer. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Brice D. Ruth Sr. IT Analyst Fiskars Brands, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tiles And Images
I use tiles and stylesheet to display my web pages. I also try to insert some images in those pages. The tiles work fine. I have header, footer, navbar, content, etc. displayed without problem. But, I am curious to know if anybody has had difficulties in inserting images. I have tried various ways and cannot succeed. __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tile and html:img
Thanks for the advices that have been given to my earlier question regarding inserting images while using tiles. The tiles part works fine. The browser still has problem to pick up the image that I try to insert. This is what I do: 1. I have html:base/ inside the HEAD tage in the main JSP page. 2. I use the following code in the header.jsp TR TD ALIGN=CENTER html:img page=images/goldbrush.gif border=0 alt=[goldbrush]//TD /TR 3. The header.jsp is in the ApplicationRoot/article/common folder 4. The images folder is where the header.jsp is; i.e., in the ApplicationRoot/article/common folder 5. I checked the spelling; including upper/lower cases, of the path and the name of the image. I also checked the extension of the image. I sort of think it is the path problem. Please comment on what I did. Thank you. __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tile and html:img
Thanks a lot, Cal. I did View Source and saw my mistake. The path of the image should be relative to the application root. --- Holman, Cal [EMAIL PROTECTED] wrote: Where is the template.jsp? Can you do view source and provide the generated link for the image tag? Cal -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Friday, October 24, 2003 21:10 To: [EMAIL PROTECTED] Subject: Tile and html:img Thanks for the advices that have been given to my earlier question regarding inserting images while using tiles. The tiles part works fine. The browser still has problem to pick up the image that I try to insert. This is what I do: 1. I have html:base/ inside the HEAD tage in the main JSP page. 2. I use the following code in the header.jsp TR TD ALIGN=CENTER html:img page=images/goldbrush.gif border=0 alt=[goldbrush]//TD /TR 3. The header.jsp is in the ApplicationRoot/article/common folder 4. The images folder is where the header.jsp is; i.e., in the ApplicationRoot/article/common folder 5. I checked the spelling; including upper/lower cases, of the path and the name of the image. I also checked the extension of the image. I sort of think it is the path problem. Please comment on what I did. Thank you. __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Learn more about Paymentech's payment processing services at www.paymentech.com THIS MESSAGE IS CONFIDENTIAL. This e-mail message and any attachments are proprietary and confidential information intended only for the use of the recipient(s) named above. If you are not the intended recipient, you may not print, distribute, or copy this message or any attachments. If you have received this communication in error, please notify the sender by return e-mail and delete this message and any attachments from your computer. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
To the Person Asked About Form-Based Container-Managed (JDBCRealm) Authentication Question
Hi, I saw your message asking me about the form-based container-managed authentication in Struts. I accidentally deleted your message and could not find your name and e-mail address. The following steps are what should be done: 1. configure the JDBCRealm in the Tomcat server.xml, see http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html 2. container-managed, form-based authentication is completely handled by the server. That is to say, it is none of Struts business. Prepare your logon.jsp and error.jsp (do not use Struts tags). There is nothing wrong with your j_security_check, ..., etc. 3. in your web.xml, you have login-config auth-methodFORM/auth-method form-login-config form-login-page/signin/logon.jsp/form-login-page form-error-page/signin/error.jsp/form-error-page /form-login-config /login-config 4. Do not change your action forward in the struts-config.xml file (i.e. do not forward anything to logon.jsp because it has nothing to do with Struts) except add redirect=true. For example: forward name=logon redirect=true path=/do/admin/Menu/ Craig McClanahan wrote a detailed explanation on how it works (I am quoting what Craig said below): form-based login is triggered the first time that an unauthenticated user requests a URL that is protected by a security constraint. (1) Unauthenticated user requests a protected resource (*NOT* the login page!) (2) Container remembers the protected resource that was requested in a private variable. (3) Container displays the login page, which must have a destination of j_security_check, and waits for the user submit. For some containers, including Tomcat, this is the one-and-only time that submitting to j_security_check will not return a 404. (4) User enters username and password, and presses the submit button. (5) the post to j_security_check is intercepted by your servlet container, which performs Container Managed Authentication - it looks for the j_username and j_password, authenticates the combination, and forwards to the originally requested resource, or to a configurable error page if the authentication (6) Container authenticates the username (j_username) and password (j_password) combination. If valid, container recalls the originally requested resource saved in (2) and displays *that* to the user in response to the login submit. Or forwards to a configurable error page if the authentication fails. The important point is that, at no time, did anyone ever submit a request to the URL of the login page, because there is no such thing. Also think of the login page as part of the container, not part of your app. Let me know if you have further questions. -Caroline __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How To Use request.tld?
Where can I find any doc regarding how to use request.tld? I have seen request.tld be imported in a JSP and the role of the logged-in user is validated this way: req:isUserInRole role=administrator I would like to find out how to use the request.tld to express this statement: user.setName( request.getRemoteUser ); __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: User Authentication implemented in Struts
My question is similar. I use container-managed role-based security checking. I put role property in Action Mapping and use isUserInRole in my JSPs. For example, John can view the sales reports if he has the sales role. Now, I want to further restrict John to view the sales reports in is region only. People say that I can use the servlet filter. I need guidance to see some examples. --- Adam Hardy [EMAIL PROTECTED] wrote: On 10/22/2003 10:21 PM Ramadoss Chinnakuzhandai wrote: apologize for repeating my question againI'm newbie to Struts and hv basic doubt in security level implemented using Struts framework. we are aware that in normal J2EE application we are authenticating user based on user access level specified in web-app in web.xml(web container) My Questions are 1.Are we following the same process of authenticating a user against his/her access level as that of the above...? if not pls explain how you are authentication a user in your struts-based application. 2.If yes to the above question Is there someother way of authenticating a user available in Sturts? If so pls explain how you are authentication a user? Yes to both: struts leverages the built-in container managed security as specified by the servlet spec from Sun. Adam -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope (URGENT)
I am also in trouble. My problem is sort of related to yours although not directly relevant. I am also looking for org.apache.struts.taglib.html.BEAN I am trying to modify Ted Husted's artimus_1_1 example - I want to add one more property to his articleForm. To submit an article in the artimus_1_1 example, his form.jsp in the /article/content folder asks for title, author, and article. I inserted one more text field: TR TD class=label nowrapJournal Category:/TD TD class=input html:text property=journal_category size=30 maxlength=75//TD /TR to indicate the academic field of the article. I got the error message: ServletException in: /article/content/form.jsp No getter method for property journal_category of bean org.apache.struts.taglib.html.BEAN Really wish someone could help me out. --- lover birds [EMAIL PROTECTED] wrote: I did not get single reply, so thought of posting this mail again. I hope I am making some sense by asking this question.Please guide me ASAP as I am newbie and stuck very badly lover birds [EMAIL PROTECTED] wrote: Hi folks, I am getting this error. Cannot find bean org.apache.struts.taglib.html.BEAN in any scope I am trying something as follows: input=/pages/count/List.jsp path=/New scope=request/ content of List.jsp is New.jsp is absolutely blank: Click on the New image of the List JSP gives me this error. I would appreciate help in this regard. I would like to know the best way to forward to a specific page on an image click. - Do you Yahoo!? The New Yahoo! Shopping - with improved product search - Do you Yahoo!? The New Yahoo! Shopping - with improved product search __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Keep Them In the Database Or In the Properties File?
I have to prepare many drop down lists for visitors of the website to make selections. For example, I have the 51 states of the United States prepared like Virginia=VA, ., etc. Do I keep the data in a database or in a properties file? __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Java Compiler Cannot Find the Required JAR File in the Classpath
I posted this problem before. Max and Carey answered my post right away. I tried and tried I must be missing something. I really do not understand why all of a sudden that the java compiler cannot find the required JARs in the classpath. I have done some similar compilation before successfully. My head is not sober enough to pinpoint the problem this time. I am doing the compilation manually (I am not using ANT or any IDE). 1. I have the commons-scaffold.jar in my $TOMCAT_HOME/webapps/PracticeVersion/WEB-INF/lib folder. 2. I have the struts.jar in both $TOMCAT_HOME/webapps/PracticeVersion/WEB-INF/lib folder and j2sdk1.4.1_02/jre/lib/ext folder 3. in my java program (Bean.java), I import org.apache.commons.scaffold.text.ConvertUtils; import org.apache.commons.scaffold.util.ProcessBeanBase; import org.apache.commons.scaffold.lang.Tokens; 4. I first set the classpath C:\set CLASSPATH=C:\jakarta-tomcat-4.1.18-LE-jdk14/webapps/PracticeVersion/WEB-INF/src/java;%CLASSPATH% then, I go to the folder where Bean.java is C:\cd jakarta-tomcat-4.1.18-LE-jdk14/webapps/PracticeVersion/WEB-INF/src/java/org/apache/artimus/article then, I try to compile and put the class file in the destination folder C:\jakarta-tomcat-4.1.18-LE-jdk14/webapps/PracticeVersion/WEB-INF/src/java/org/apache/artimus/articlejavac -d C:\jakarta-tomcat-4.1.18-LE-jdk14/webapps/PracticeVersion/WEB-INF/classes Bean.java But, I get compilation error: package org.apache.commons.scaffold.text does not exist package org.apache.commons.scaffold.util does not exist package org.apache.commons.scaffold.lang does not exist __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Where Do I Create Session, Set Attributes in Struts?
I use container-managed form-based authentication to verify users (it works well). Now, I want to create a session and set user's name after users successfully log in: HttpSession session = request.getSession( true ); if ( session.isNew() ) { student.setName(request.getParameter(username)); session.setAttribute(student, student); Student stud = (Student)session.getAttribute(student); } First of all, in the context of container managed authentication, can I write: student.setName(request.getParameter(username)); Second, what is the proper place to insert the aforementioned codes. The container intercepts and takes care of the authentication when forward name=logon redirect=true path=/do/Menu/ and the action controller is in the scaffold folder: action path=/Menu name=menuForm type=org.apache.struts.scaffold.ExistsAttributeAction parameter=application;HOURS forward name=success path=.article.Menu/ forward name=failure path=/do/MenuCreate/ /action where .article.Menu is a tile. __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Compilation Problem. Help!
I have all the required jar files in the MyApp/WEB-INF/lib directory. Please help me in identifying the problems with compilation: 1. For example, I have the commons-scaffold.jar in my $TOMCAT_HOME/webapps/MyApp/WEB-INF/lib folder. 2. I have the struts.jar in the j2sdk1.4.1_02/jre/lib/ext folder 3. in my java class, I import org.apache.commons.scaffold.text.ConvertUtils; import org.apache.commons.scaffold.util.ProcessBeanBase; import org.apache.commons.scaffold.lang.Tokens; But, I get compilation error: package org.apache.commons.scaffold.text does not exist package org.apache.commons.scaffold.util does not exist package org.apache.commons.scaffold.lang does not exist __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How To Work Out This Action Mapping?
Craig, thank you for your very strong support in the past day or two to guide me through problems with the container-managed authentication. I looked at my web.xml file again and again. There is nothing wrong with the order of the elements in that file. And there is no stack trace in the log files that talks about an XML parsing error. I did some experiments. I found that as long as I have the JDBCRealm in the $TOMCAT_HOME/conf/server.xml, the Tomcat does not accept security-constraint element in the application's web.xml file. And the Tomcat gives me the required resouce /MyApplication is not availabel HTTP Status 404. Have you seen this kind of problem before? I have posted the question at the tomcat-user discussion forum. --Caroline --- Craig R. McClanahan [EMAIL PROTECTED] wrote: Caroline Jen wrote: To answer your questions: 1. The LOGON button links to a forward: html:link forward=logonLOGON/html:link and in my struts-config.xml, I have forward name=logon path=/do/admin/Menu/ Well, that's the first problem ... security constraints are only applied on an original request from the client, not on a forward. You'll need to add redirect=true to this, in order to get the client to request it. 2. the security-constraint in my web-xml is: security-constraint web-resource-collection web-resource-nameAdministrative/web-resource-name !-- The URLs to protect -- url-pattern/do/admin/*/url-pattern /web-resource-collection auth-constraint !-- The authorized users -- role-nameadministrator/role-name role-namecontributor/role-name /auth-constraint /security-constraint By the way, there is another problem -- after the insertion of the security-constraint, the application totally stops functioning. No welcome page displayed. In the browser, I have HTTP Status 404 -/PracticeVersion description: The requested resource(/PracticeVersion) is not availabe. and in the Tomcat log file, I have: LifecycleException: Container StandardContext[/PracticeVersion] has not been started That means you did not obey the required element order in the web.xml file. You'll undoubtedly see a stack trace in the log files that talks about an XML parsing error. The correct order is defined by the DTD for web.xml files. Among other places, you'll find a copy of the DTDs for Servlet 2.2 and Servlet 2.3 in the lib directory of your Struts distribution. Open either web_app_2_2.dtd or web_app_2_3.dtd (depending on which version you're using) and look for the line that starts !ELEMENT webapp The list of element names in parentheses is the required order for elements in your own web.xml files. Thereafter, I deleted the security-constraint element from the web.xml file. I have the welcome page displayed. After I click on the LOGON button in the welcome page, the welcome page remains in the browser. The logon.jsp, which collects j-username, j_password, does not get displayed and http://localhost:8080/PracticeVersion/do/admin/Menu shows in the address bar. Change your forward to add redirect=true and put the security constraint in the correct order, and you should be good to go. --Caroline Craig --- Craig R. McClanahan [EMAIL PROTECTED] wrote: Caroline Jen wrote: Thank you very much for the detailed explanation. Yet, I still have hard time to make my application work -- I am able to display the welcome page (no problem). And I have http://localhost:8080/PracticeVersion/do/Menu;jsessionid=0A6E76A8F3E849BC8DAAC45BFB72F72E in the address bar. However, after I click on the LOGON button in the welcome page, the welcome page Where does this LOGON button submit to? If it submits to j_security_check, you are doing this wrong. It should submit to some resource that is protected by a security constraint. remains in the browser. The logon.jsp, which collects j-username, j_passwor, does not get displayed and http://localhost:8080/PracticeVersion/do/admin/Menu shows in the address bar. I do not know what went wrong. Could it be that the JDBCRealm is not configured correctly? Because the LOGON button links to a forward: html:link forward=logonLOGON/html:link and in my struts-config.xml, I have forward name=logon path=/do/admin/Menu/ The /do/admin/Menu is my protected resources. I keep it unchanged. It's only protected if it's listed in a security-constraint in web.xml. 1. I configured the Tomcat JDBCRealm and prepared the users table, user-roles table according the instructions found at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html
HTTP Status 404 After Inserting security-constraint In The web.xml
I think this is more of a problem in the area of Servlets/JSPs. Nonetheless, it happened when I ran my Struts application and I decided to give a try at this forum. My application worked well with login-config auth-methodFORM/auth-method form-login-config form-login-page/signin/logon.jsp/form-login-page form-error-page/signin/logon.jsp?error=true/form-error-page /form-login-config /login-config in the web.xml file. Thereafter,I inserted security-constraint preceding the login-config element, and inserted security-role following the login-config element. The application stopped functioning. I got: HTTP Status 404 -/PracticeVersion description: The requested resource(/PracticeVersion) is not availabe. in the browser, and I have this message in the Tomcat log file: LifecycleException: Container StandardContext[/PracticeVersion] has not been started This was what my web.xml looked like when the problem happened: security-constraint web-resource-collection web-resource-nameAdministrative/web-resource-name !-- The URLs to protect -- url-pattern/do/admin/*/url-pattern /web-resource-collection auth-constraint !-- The authorized users -- role-nameadministrator/role-name role-namecontributor/role-name /auth-constraint /security-constraint login-config auth-methodFORM/auth-method form-login-config form-login-page/signin/logon.jsp/form-login-page form-error-page/signin/logon.jsp?error=true/form-error-page /form-login-config /login-config security-role role-nameadministrator/role-name /security-role security-role role-namecontributor/role-name /security-role __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How To Work Out This Action Mapping?
Because there is such a statement (shown below) in my signinForm.jsp: html:form action=j_security_check method=post focus=j_username I put action name=j_security_check path=/do/admin/Menu/ in my struts-config.xml file. When I ran the application, I got: [ServletException in:/article/content/signinForm.jsp] Cannot retrieve mapping for action /j_security_check' I know that I did not specify the action properly. What is the correct way to do it? __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How To Work Out This Action Mapping?
Thank you for your reply. I am using container managed authentication. My problem is how to go from j_security_check back to my Struts framework. I have my Tomcat JDBCRealm configured and users, user_roles tables prepared in the database. In my struts-config.xml file, I did this forward when users click on the LOGON button: forward name=logon path=/signin/logon.jsp/ and in my web.xml file, I have: login-config auth-methodFORM/auth-method form-login-config form-login-page/signin/logon.jsp/form-login-page form-error-page/signin/logon.jsp?error=true/form-error-page /form-login-config /login-config The Tomcat server found the signinForm.jsp through the /signin/logon.jsp without problem. and my signinForm.jsp is correctly prepared: %@ taglib uri=/tags/struts-html prefix=html % HTML HEAD TITLEContainer Managed Authentication/TITLE /HEAD BODY html:errors/ html:form action=j_security_check method=post focus=j_username TABLE border=0 width=100% TR TH align=rightUser Name:/TH TD align=lefthtml:text property=j_username size=25//TD /TR TR TH align=rightPassword:/TH TD align=lefthtml:password property=j_password size=10//TD /TR TR TD align=righthtml:submit//TD TD align=lefthtml:reset//TD /TR /TABLE /html:form /BODY /HTML --Caroline --- Sasha Borodin [EMAIL PROTECTED] wrote: I think you may be doing two things wrong: 1. j_security_check is a special URL. If you have a security realm defined in your web application, and authentication method specified as FORM, then the container will automatically forward any requests for protected resources to a configurable login form. This login form collects the username and password, and posts to this special URL; the post to j_security_check gets intercepted by your servlet container, which performs Container Managed Authentication - it looks for the j_username and j_password, authenticates the combination, and forwards to the originally requested resource, or to a configurable error page if the authentication fails. All this to say that you can not map an action to j_security_check. Furthermore, you can't even aggressively authenticate using CMA (Container Managed Authentication) - if you go directly to your login page (without being forwarded there by you container), and try to submit the form, you'll get an error. 2. If you were trying to map a legitimate URL, then you'd have your action properties wrong. action path=/someLegitimatePath type=your.action.class name=name of a previously defined ActionForm if needed for this action /action HTH, -Sasha On 10/10/03 20:21, Caroline Jen [EMAIL PROTECTED] wrote: Because there is such a statement (shown below) in my signinForm.jsp: html:form action=j_security_check method=post focus=j_username I put action name=j_security_check path=/do/admin/Menu/ in my struts-config.xml file. When I ran the application, I got: [ServletException in:/article/content/signinForm.jsp] Cannot retrieve mapping for action /j_security_check' I know that I did not specify the action properly. What is the correct way to do it? __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.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] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How To Work Out This Action Mapping?
Thank you very much for the detailed explanation. Yet, I still have hard time to make my application work -- I am able to display the welcome page (no problem). And I have http://localhost:8080/PracticeVersion/do/Menu;jsessionid=0A6E76A8F3E849BC8DAAC45BFB72F72E in the address bar. However, after I click on the LOGON button in the welcome page, the welcome page remains in the browser. The logon.jsp, which collects j-username, j_passwor, does not get displayed and http://localhost:8080/PracticeVersion/do/admin/Menu shows in the address bar. I do not know what went wrong. Could it be that the JDBCRealm is not configured correctly? Because the LOGON button links to a forward: html:link forward=logonLOGON/html:link and in my struts-config.xml, I have forward name=logon path=/do/admin/Menu/ The /do/admin/Menu is my protected resources. I keep it unchanged. 1. I configured the Tomcat JDBCRealm and prepared the users table, user-roles table according the instructions found at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html 2. Because I want to use FORM based container managed authentication, I inserted login-config auth-methodFORM/auth-method form-login-config form-login-page/signin/logon.jsp/form-login-page form-error-page/signin/logon.jsp?error=true/form-error-page /form-login-config /login-config in the web.xml file. 3. I put logon.jsp in the ApplicationRoot/signin folder. Here is the code of the logon.jsp (I took out all the Struts tags) and I know the code works well because I have tested it: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN HTML HEAD TITLEContainer Managed Authentication/TITLE /HEAD BODY H1Sign in, Please/H1 HR FORM action=j_security_check method=post focus=j_username TABLE border=0 width=50% cellspacing=3 cellpadding=2 TR TH align=rightUser Name:/TH TD align=leftINPUT TYPE=text NAME=j_username SIZE=25//TD /TR TR TH align=rightPassword:/TH TD align=leftINPUT TYPE=password NAME=j_password SIZE=10//TD /TR TR TD align=rightINPUT TYPE=submit VALUE=Submit/TD TD align=leftINPUT TYPE=reset VALUE=Reset/TD /TR /TABLE /FORM /BODY --Caroline --- Craig R. McClanahan [EMAIL PROTECTED] wrote: Caroline Jen wrote: Thank you for your reply. I am using container managed authentication. My problem is how to go from j_security_check back to my Struts framework. That turns out to not be your problem ... that is the container's problem. The key thing to remember is that the user should never access your login page (whatever it's URL is) directly. Instead, form-based login is triggered the first time that an unauthenticated user requests a URL that is protected by a security constraint. What happens next goes like this: (1) Unauthenticated user requests a protected resource (*NOT* the login page!) (2) Container remembers the protected resource that was requested in a private variable. (3) Container displays the login page, which must have a destination of j_security_check, and waits for the user submit. For some containers, including Tomcat, this is the one-and-only time that submitting to j_security_check will not return a 404. (4) User enters username and password, and presses the submit button. (5) Container authenticates the username and password combination. If valid, container recalls the resource saved in (2) and displays *that* to the user in response to the login submit. If this doesn't make sense, temporarily switch your app to use BASIC authentication instead, and walk through the process. The user experience will be identical except that the login page will be a popup dialog box instead of your configured login page. (Technically, it's different in one other respect -- it's the *browser* that does the remembering in step (2) and the restoring in step (5), but the user doesn't know that). The important point is that, at no time, did anyone ever submit a request to the URL of the login page, because there is no such thing when using BASIC authentication. You should pretend there is no such thing when using form based login, also; think of the login page as part of the container, not part of your app. In answer to your original question, the simplest thing to do on a login page is just use the standard HTML form element instead of the Struts html:form tag. Then, you can just say: form method=POST action=j_security_check ... /form Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail
Re: How To Work Out This Action Mapping?
To answer your questions: 1. The LOGON button links to a forward: html:link forward=logonLOGON/html:link and in my struts-config.xml, I have forward name=logon path=/do/admin/Menu/ 2. the security-constraint in my web-xml is: security-constraint web-resource-collection web-resource-nameAdministrative/web-resource-name !-- The URLs to protect -- url-pattern/do/admin/*/url-pattern /web-resource-collection auth-constraint !-- The authorized users -- role-nameadministrator/role-name role-namecontributor/role-name /auth-constraint /security-constraint By the way, there is another problem -- after the insertion of the security-constraint, the application totally stops functioning. No welcome page displayed. In the browser, I have HTTP Status 404 -/PracticeVersion description: The requested resource(/PracticeVersion) is not availabe. and in the Tomcat log file, I have: LifecycleException: Container StandardContext[/PracticeVersion] has not been started Thereafter, I deleted the security-constraint element from the web.xml file. I have the welcome page displayed. After I click on the LOGON button in the welcome page, the welcome page remains in the browser. The logon.jsp, which collects j-username, j_password, does not get displayed and http://localhost:8080/PracticeVersion/do/admin/Menu shows in the address bar. --Caroline --- Craig R. McClanahan [EMAIL PROTECTED] wrote: Caroline Jen wrote: Thank you very much for the detailed explanation. Yet, I still have hard time to make my application work -- I am able to display the welcome page (no problem). And I have http://localhost:8080/PracticeVersion/do/Menu;jsessionid=0A6E76A8F3E849BC8DAAC45BFB72F72E in the address bar. However, after I click on the LOGON button in the welcome page, the welcome page Where does this LOGON button submit to? If it submits to j_security_check, you are doing this wrong. It should submit to some resource that is protected by a security constraint. remains in the browser. The logon.jsp, which collects j-username, j_passwor, does not get displayed and http://localhost:8080/PracticeVersion/do/admin/Menu shows in the address bar. I do not know what went wrong. Could it be that the JDBCRealm is not configured correctly? Because the LOGON button links to a forward: html:link forward=logonLOGON/html:link and in my struts-config.xml, I have forward name=logon path=/do/admin/Menu/ The /do/admin/Menu is my protected resources. I keep it unchanged. It's only protected if it's listed in a security-constraint in web.xml. 1. I configured the Tomcat JDBCRealm and prepared the users table, user-roles table according the instructions found at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html Which Realm you use does not make any difference. 2. Because I want to use FORM based container managed authentication, I inserted login-config auth-methodFORM/auth-method form-login-config form-login-page/signin/logon.jsp/form-login-page form-error-page/signin/logon.jsp?error=true/form-error-page /form-login-config /login-config in the web.xml file. What does your security-constraint in web.xml look like? This is the critical ingredient. 3. I put logon.jsp in the ApplicationRoot/signin folder. Here is the code of the logon.jsp (I took out all the Struts tags) and I know the code works well because I have tested it: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN HTML HEAD TITLEContainer Managed Authentication/TITLE /HEAD BODY H1Sign in, Please/H1 HR FORM action=j_security_check method=post focus=j_username TABLE border=0 width=50% cellspacing=3 cellpadding=2 TR TH align=rightUser Name:/TH TD align=leftINPUT TYPE=text NAME=j_username SIZE=25//TD /TR TR TH align=rightPassword:/TH TD align=leftINPUT TYPE=password NAME=j_password SIZE=10//TD /TR TR TD align=rightINPUT TYPE=submit VALUE=Submit/TD TD align=leftINPUT TYPE=reset VALUE=Reset/TD /TR /TABLE /FORM /BODY --Caroline Craig --- Craig R. McClanahan [EMAIL PROTECTED] wrote: Caroline Jen wrote: Thank you for your reply. I am using container managed authentication. My problem is how to go from j_security_check back to my Struts framework. That turns out to not be your problem ... that is the container's problem. The key thing to remember is that the user should never access your login page (whatever it's URL is) directly. Instead, form-based login is triggered the first time that an unauthenticated user requests a URL that is protected by a security constraint. What happens next goes like this: (1) Unauthenticated user requests a protected resource (*NOT* the login page
What Is Wrong With My web.xml File (Struts)
My Struts application worked well until I added security in the web.xml file. I got the error message shown below and I cannot spot any mistake with my eyes: [QUOTE] 2003-10-08 23:33:25 Exception initializing TldLocationsCache: XML parsing error on file /WEB-INF/web.xml: (line 137, col 19): The content of element type security-role must match (description?,role-name). [/QUOTE] and my web.xml file is: [CODE] ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN http://java.sun.com/j2ee/dtds/web-app_2_2.dtd; web-app !-- Configuring Artimus -- servlet servlet-nameartimus/servlet-name servlet-classorg.apache.artimus.http.ArtimusServlet/servlet-class !-- Our application properties -- init-param param-namedefault/param-name param-valueresources/artimus.properties/param-value /init-param !-- Our connection adaptor -- init-param param-nameadaptor/param-name param-valueorg.apache.commons.scaffold.sql.PoolmanAdaptor/param-value /init-param init-param param-nameadaptor.key/param-name param-valuejdbc-artimus/param-value /init-param !-- Alternate adaptors init-param param-nameadaptor/param-name param-valueorg.apache.commons.scaffold.sql.ServletAdaptor/param-value /init-param init-param param-nameadaptor.key/param-name param-valueorg.apache.struts.action.DATA_SOURCE/param-value /init-param init-param param-nameadaptor/param-name param-valueorg.apache.commons.scaffold.sql.ConnectionAdaptor/param-value /init-param init-param param-nameadaptor.key/param-name param-valuejdbc/artimus/param-value /init-param -- !-- Our startup priority -- load-on-startup1/load-on-startup /servlet !-- Standard Struts configuration -- servlet servlet-nameaction/servlet-name !-- org.apache.struts.tiles.ActionComponentServlet -- servlet-classorg.apache.struts.action.ActionServlet/servlet-class init-param param-nameconfig/param-name param-value/WEB-INF/struts-config.xml/param-value /init-param init-param param-namedebug/param-name param-value2/param-value /init-param init-param param-namedetail/param-name param-value2/param-value /init-param init-param param-namenull/param-name param-valuefalse/param-value /init-param !-- Startup priority -- load-on-startup2/load-on-startup /servlet !-- servlet-mappings, welcome-file-list -- servlet-mapping servlet-nameaction/servlet-name url-pattern/do/*/url-pattern /servlet-mapping welcome-file-list welcome-fileindex.jsp/welcome-file /welcome-file-list !-- taglibs -- taglib taglib-uri/tags/struts-bean/taglib-uri taglib-location/WEB-INF/lib/struts-bean.tld/taglib-location /taglib taglib taglib-uri/tags/struts-html/taglib-uri taglib-location/WEB-INF/lib/struts-html.tld/taglib-location /taglib taglib taglib-uri/tags/struts-logic/taglib-uri taglib-location/WEB-INF/lib/struts-logic.tld/taglib-location /taglib taglib taglib-uri/tags/tiles/taglib-uri taglib-location/WEB-INF/lib/struts-tiles.tld/taglib-location /taglib taglib taglib-uri/tags/request/taglib-uri taglib-location/WEB-INF/lib/request.tld/taglib-location /taglib !-- Our secuity settings -- security-constraint web-resource-collection web-resource-nameAdministrative/web-resource-name !-- The URLs to protect -- url-pattern/*/url-pattern /web-resource-collection auth-constraint !-- The authorized users -- role-nameadministrator/role-name role-nameadvisor/role-name role-nameeditor/role-name role-namecontributor/role-name /auth-constraint user-data-constraint transport-guaranteeNONE/transport-guarantee /user-data-constraint /security-constraint login-config auth-methodFORM/auth-method form-login-config form-login-page/signin/logon.jsp/form-login-page form-error-page/signin/logon.jsp?error=true/form-error-page /form-login-config /login-config !-- Our authentification strategy -- security-role descriptionRegistered Members/description role-nameadministrator/role-name role-nameadvisor/role-name role-nameeditor/role-name role-namecontributor/role-name /security-role // line 137 is here /web-app [/CODE] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Container-Managed Authentication login-config in web.xml vs . Specifying Paths in the struts-config.xml
People answer questions without reading my original post. Therefore, I must re-type my original question again. Before I posted my question, I had configured the Tomcat JDBCRealm following the instructions at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html so that I can do security testing programmically, such as isUserInRole(), in my program. If I use form based authentication, I insert the login-config and its sub-elements in my web.xml file (see below). As we know, the form-login-page and form-error-page are required. My question is that the container-managed authentication (we provide login page and error page in the web.xml) does not seem to be consistent with what we usually do in struts; e.g. we state the logical name and path for each .jsp page in the struts-config.xml file. What is the Struts convention in dealing with user authentication? Should we specify the paths for the logon page and error page in the struts.config.xml or we should use the form-login-page and form-error-page in the web.xml file? Thanks. --- Craig R. McClanahan [EMAIL PROTECTED] wrote: Caroline Jen wrote: But, I do not want to use BASIC authentication. I have many different roles and hundreds of people per role. Users' name, role, etc. are stored in a database. How authentication is performed (BASIC, form-based, DIGEST, or SSL client certificates) and how users are stored (database, directory server, local XML file, ...) are two separate questions. For most servers , any combination is possible. With Tomcat, for example, you can configure JDBCRealm to point at your user and role definitions in a database, and then use those users with any of the authentication methods. For more information, see: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html The choice between BASIC and form-based authentication, then, can be based on user interface related concerns, rather than worrying about a database. Craig --- Matt Raible [EMAIL PROTECTED] wrote: A JDBCRealm can use BASIC authentication - it doesn't require form-based. Here's an example app that might help you out: http://raibledesigns.com/wiki/Wiki.jsp?page=SecurityExample HTH, Matt -Original Message- From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Monday, October 06, 2003 4:45 PM To: [EMAIL PROTECTED] Subject: Container-Managed Authentication login-config in web.xml vs. Specifying Paths in the struts-config.xml I use the Tomcat. I configured the Tomcat JDBCRealm so that I can use programmic security testing, such as isUserInRole(), in my program. Because Tomcat JDBCRealm is form based, I inserted the login-config and its sub-elements in my web.xml file (see below). As we know, the form-login-page and form-error-page are required. My question is that the container-managed authentication does not seem to be consistent with what we usually do in struts; e.g. we state the logical name and path for each .jsp page in the struts-config.xml file. What is the Struts convention in dealing with user authentication? Should we specify the paths for the logon page and error page in the struts.config.xml or we should use the form-login-page and form-error-page in the web.xml file? == security-constraint web-resource-collection web-resource-nameSalesInfo/web-resource-name url-pattern/SalesInfo/*/url-pattern http-methodGET/http-method http-methodPOST/http-method /web-resource-collection auth-constraint role-namemanager/role-name /auth-constraint user-data-constraint transport-guaranteeNONE/transport-guarantee /user-data-constraint /security-constraint login-config auth-methodFORM/auth-method form-login-config form-login-page/authentication/login.html/form-login-page form-error-page/authentication/error.html/form-error-page /form-login-config /login-config security-role role-namemanager/role-name /security-role __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.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] __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e