Double submit handling using struts tokens

Hi,
I am using struts token to handle double submit.
The way i have implemented is,
wrote a base Action class.
Inside the BaseAction class i have overriden the resetToken method like this,
synchronized public void resetToken(javax.servlet.http.HttpServletRequest request) {
     javax.servlet.http.HttpSession session;
     session = request.getSession(false);
     if (session == null) {
     return;
     session.removeAttribute("org.apache.struts.action.TOKEN");
saveToken(request);
I m calling saveToken inside resetToken for new pages.
So how it would work is first time in my action i would call saveToken which would set token in my jsp page and then in respective actions i would check if isTokenValid(),
and then call resetToken so that i would clear the old on and set the new one for the new jsp page.
Is that the right way i m doing it ?
Please suggest me if there is better way to handle it.
Thanks
Abbyss

You can use isTokenValid(request, true) which will automatically call resetToken() after checking the token.
Izida

Similar Messages

  • Using Struts, On submit button in child window, its opening new window.

    We are developing a project using Struts and BC4J. I am opening a child window(window.showmodaldialog) from main window using struts action. Actually Child window is a search kind of page. User will enter the search criteria and press the sumbit button. I want to display the search result in the same window using datatable when jboevent="submit". But its opening new window and displaying the result in that. However in <html:form>, Even I tried the target="_self".
    I am not sure wether the associated action in the <html:form> is forcing to open a new window.
    Similar kind of thing I am able to achieve in other similar search page, it its not a child window.
    Please let me know what I am missing.
    Thanks,
    Arvind

    So you want the search window to submit back to itself so you see the search field and a result list..?
    In pure Struts terms either using "_self" or the name of the popup window in the <html:form> tag will do the trick
    You need to make sure that the inital window that you created as the popup search window has a name in the first place - can you specify this with showModalDialog()?
    BTW isn't showModalDialog an IE only feature...

  • JSF analogous to Struts Tokens?

    Hi!
    I would like to know if there is any feature in JSF that is similar to Struts Tokens?
    My Specific requirement is :
    After filling the form (in a wizard kind of interface)the fields would be persisted , but the user might click the back button to make sure that he entered the data correctly, and then may click next
    button, which triggers a duplicate data error, because the user has already entered the data ,and that is persisted.
    In Struts we would do Action .savetokens in the submit action
    and check for the validity of the token by caling Action.isTokenValid(),if the conditions is true, thaty means the form has been already submitted.
    Like wise is there any thing that resembles this feature of Struts in JSF ?
    May be savestate and restorestate could be a solution..
    Any thoughts..?
    Regards,
    Samba

    Hi! Simon,
    From Apache trinidad Documentation :
    Some Apache Trinidad configuration options are set instead with <context-param> elements in your WEB-INF/web.xmlfile.
    org.apache.myfaces.trinidad.CACHE_VIEW_ROOT
    Enables or disables UIViewRoot caching; defaults to true.
    When "token" client-side state saving is enabled, Trinidad applies an additional optimization by caching an entire UIViewRoot tree with each token. (Care has been taken to ensure that this does not affect thread safety or session failover.) This is a major optimization for AJAX-intensive systems, as postbacks can be processed far more rapidly without the need to reinstantiate the UIViewRoot tree. However, it is known to interfere with some other JSF technologies. In particular, the Apache MyFaces Tomahawk saveState component does not work, and template text in Facelets may appear in duplicate. This optimization can be disabled by setting this context parameter to false.
    org.apache.myfaces.trinidad.CLIENT_STATE_METHOD
    Chooses the type of client-side state saving used when client-side state saving is enabled (with the JSF standard javax.faces.STATE_SAVING_METHOD parameter). Two values are accepted:
    * "token": the default, which stores page state in the session, but persists a token to the client that lets Apache Trinidad disambiguate the same page appearing multiple times. Failover is supported.
    * "all": stores all state in the client in a (potentially large) hidden form field. This matches the default behavior of the JSF reference implementation, and can be useful for developers avoiding any use of HttpSession.
    org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS
    In "token"-based client-side state saving, chooses how many tokens should be preserved at any one time. The default value is 15. When this is exceeded, state will have effectively been "forgotten" for the least recently viewed pages, which can impact users that actively use the Back button or that have multiple windows open simultaneously. Developers building HTML applications that rely heavily on frames will likely need to increase this value.
    org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE
    This configuration option enables an optimized strategy for caching some view state at an application level, which significantly improves scalability. However, it makes it harder to develop (updates to pages will not be noticed until the server is restarted), and in some rare cases cannot be used for some pages. See below for more information about this option.
    What i'm interested in knowing more about is this :
    We can get the token written to the Web page as a ViewState hidden variable by calling facesContext.saveState();
    Can we use this token to Compare whether the user has already submitted a request, and identify that he now posting a duplicate request?
    I'll give it a try,any way.
    And coming to your suggestion of using pageFlowScope ----
    We regularly use that to save a flag which is set to true on form submission ,and corresponding persistence ,and later if the user clicks the back button,and submits the form again, we'll check for the flag ,and since the value is true, we would silently continue with the decision to move to the next page this time leaving out persistence;unless ,of course in the scenario where the form fields might have changed in the second submission of the form in which case , we need to update the values that have already been entered ... and this involves a lot many issues to discuss ,than mentioned here.
    but my intention is to know whether there is an in-built functionality in JSF that addresses this issue as did the Struts!
    I strongly believe that viewState Token should be a very good candidate for this feature.
    Am I too idealistic ?
    Any thoughts are welcome,
    Regards,
    Samba

  • URGENT: Is it possible to upload multiple files using STRUTS

    Hi,
    Is it possible to upload multiple files using STRUTS.
    I am able to upload a single file. But how do i upload multiple files ??
    upload.jsp
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html>
    <head>
    <title>New Page 1</title>
    </head>
    <body>
    <html:form action="/secure/uploadFile.do" enctype="multipart/form-data" method="POST" type="com.smartstream.webconnect.user.actions.UploadActionForm">
    <p>File to upload
    <html:file property="fileUpload" size="20"/></p>
    <p><html:submit/></p>
    </html:form>
    </body>
    </html:html>
    UploadAction.java
    public class UploadAction extends BaseAction {
        Logger log = Logger.getLogger(AttachMessageAction.class);
        public ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ActionException {
            System.out.println("executeAction of UploadAction");
            UploadActionForm uploadActionForm = (UploadActionForm) form;
            int fileSize = uploadActionForm.getFileUpload().getFileSize();
            System.out.println("uploadActionForm.getFileUpload().getFileSize() = " + uploadActionForm.getFileUpload().getFileSize());
            byte buffer[] = new byte[1024];
            try {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(uploadActionForm.getFileUpload().getInputStream());
                FileOutputStream fos = new FileOutputStream("s:\\uploaded\\" + uploadActionForm.getFileUpload().getFileName());
                int read;
                while ( (read = bufferedInputStream.read(buffer,0,buffer.length)) != -1) {
                    fos.write(buffer, 0, read);
                fos.flush();
                fos.close();
                bufferedInputStream.close();
                return mapping.findForward("success");
            } catch (IOException e) {
                e.printStackTrace();
                return mapping.findForward("error");
            }catch(OutOfMemoryError o){
                o.printStackTrace();
                System.out.println("o.getMessage() " + o.getMessage());
                return mapping.findForward("error");
    UploadActionForm.java
    public class UploadActionForm extends ActionForm{
        private FormFile fileUpload;
        private byte[] fileContent;
        public FormFile getFileUpload() {
            org.apache.struts.taglib.html.FormTag _jspx_th_html_form_0;
            return fileUpload;
        public byte[] getFileContent() {
            return fileContent;
        public void setFileUpload(FormFile fileUpload) {
            this.fileUpload = fileUpload;
        public void setFileContent(byte[] fileContent) {
            this.fileContent = fileContent;
    }--Bhupendra Mahajan

    Yes, you could try using the multipart handler...
    But I have a better idea...
    Determine the maximum number of file uploads that the
    user can do at one time. I mean, you can't
    realistically have the user upload a million files at
    one time. So say the max is 20. So you create your
    action form class with 20 FormFile fields called file1
    to file20.
    Then when you dynamically create your page, you
    dynamically create the specified number of file fields
    and 1 hidden field called "totalFiles" which contains
    the number of file fields you created. This should be
    an int field in the form bean.
    Then when you do your action processing, you just loop
    thru the totalFiles... Or well, actually, you may not
    need that at all. You could just check all the
    FormFile fields and whatever ones aren't null contain
    files.But what about UploadActionForm.java[b]
    How do i have exact mapping of the HTML form in this file ??
    --[b]Bhupendra Mahajan

  • Struts Token Interceptor - Not working

    Hi,
    I have checked all the answers to this question on this forum but none resolve my issue.
    I need to stop the user from resubmitting the form. So naturally turned to Token interceptor
    I get the below warning and the page is redirected to global results for invalid.token:
    Apr 10, 2011 10:50:19 PM org.apache.catalina.core.StandardContext start  
    INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/VulMgmt] has already been started  
    Apr 10, 2011 10:51:13 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn  
    WARNING: Could not find token name in params.  
    Apr 10, 2011 10:51:13 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn  
    WARNING: Could not find token name in params.Here is my struts.xml config:
            <interceptors>  
                <interceptor name="mylogging" class="com.vulmgr.MyLoggingInterceptor"/>  
                <interceptor-stack name="loggingStack">  
                <interceptor-ref name="mylogging"/>  
                    <interceptor-ref name="fileUpload">  
                        <param name="maximumSize">909715200</param>  
                        <param name="allowedTypes">  
                        text/xml,application/octet-stream  
                        </param>  
                    </interceptor-ref>  
                    <interceptor-ref name="defaultStack" />  
                </interceptor-stack>  
                <interceptor-stack name="token-submit" >  
                                   <interceptor-ref name="tokenSession" />  
                                   <interceptor-ref name="loggingStack"/>  
                </interceptor-stack>  
            </interceptors>  
            <default-interceptor-ref name="loggingStack" />  
            <action name="fileUpload" class="com.vulmgr.actions.FileUploadAction">  
                <interceptor-ref name="token-submit"/>  
                <result name="success">/WEB-INF/pages/HelloWorld.jsp</result>  
                <result name="input">/WEB-INF/pages/fileupload.jsp</result>  
                <result name="error">/WEB-INF/pages/fileupload.jsp</result>  
            </action>  My JSP page snippest ( I have tried with out name attribute, using token, struts.token etc as name value but same issue).
        <s:form action="fileUpload" method="post" enctype="multipart/form-data">  
            <s:token name="doublePost"/>  
         </s:form>
    Any hints on what is missing?
    Thanks

    Solved the issue. Here it is for them who face the same problem.I made the value attribute to false from true for inputForward.This is working fine.
    <controller
    contentType="text/html;charset=UTF-8"
    debug="3"
    locale="true"
    nocache="true"
    processorClass="org.apache.struts.action.PortletRequestProcessor">
    <set-property property="inputForward" value="false"/>
    </controller>
    Thanks.....

  • How to add row of text box and combox dynamically using struts......!!!!!!!

    Hi All,
    In my JSP I have something like a row of TextBox-----Combox-----TextBox Button--Add
    When user clicks on "Add" I need to add exactly the same row as above.
    I am using struts and have following code
    My jsp
    <html:text property="paramName" size="20" maxlength="50"/>  
    <html:select property="paramTypeId">
       <html:options collection="queryReturnType" property="value" labelProperty="label" />
    </html:select>   
    <html:text property="paramDefault" size="20" maxlength="50"/>  
    <html:button property="buttonAdd" style="cursor:pointer" onclick="addRow()"> <bean:message key='button.add'/>  /html:button>  
    My actionForm
         private String[] paramName;
         private int[] paramTypeId;
         private String[] paramDefault;
    //having getter and setter method also for these three attibutesPlease help....it would be of great help if some one can give me a java script of code for adding a row like I mentioned above....!!!
    Thanks

    Hi inryji.
    Thanks for your reply..!!!
    I have written the below method to add a row and its adding also.
    But when I submit the form....value for combox is not going to the newly addedd row.
    here is my jsp code...
    <table border="0" width="75%" cellspacing="1" id="myTable">
    <tbody>
    <tr>
         <td width="80%" class="evencellleft">
              <html:text property="paramName" size="20" maxlength="50"/>  
              <html:select property="paramTypeId">
                   <html:options collection="queryReturnType" property="value" labelProperty="label" />
              </html:select>   
              <html:text property="paramDefault" size="20" maxlength="50"/>  
              <html:button property="buttonAdd" style="cursor:pointer" onclick="addRow()"> <bean:message key='button.add'/>  </html:button>  
              <html:button property="buttonDelete" style="cursor:pointer" onclick="removeRow()"><bean:message key='button.delete'/>  </html:button>
         </td>
    </tr>
    </tbody>
    </table>
    here is my java script code...
    function addRow() {
         var tbody = document.getElementById('myTable').getElementsByTagName("TBODY")[0];
         var row = document.createElement("<tr>");
         var td1 = document.createElement("<td width='80%' class='evencellleft'>");
         td1.innerHTML+="   ";
         var myElement1 = document.getElementById('paramName');
         var el1 = myElement1.cloneNode(true);
         el1.id = "";
         td1.appendChild(el1);
         td1.innerHTML+="   ";
         var myElement2 = document.getElementById('queryReturnTypeId');
         var el2 = myElement2.cloneNode(true);
         el2.id = "";
         td1.appendChild(el2);
         td1.innerHTML+="    ";
         var myElement3 = document.getElementById('paramDefault');
         var el3 = myElement3.cloneNode(true);
         el3.id = "";
         td1.appendChild(el3);
         row.appendChild(td1);
         tbody.appendChild(row);
    }Please help...!!!

  • Issue in converting Struts view to JSF view using struts-faces integration

    Hi All,
    I am facing a issue in my Sruts to JSF conversion application using struts-faces.jar integration library.
    Need expert's help desperately as I am not able to use <s:form> tag in my new jsf page to call a struts action.
    I want to call a struts action from my web page designed using JSF,
    but it seems impossible without using <s:form> tag from struts-faces integration library.
    Please suggest how to resolve this...
    I am using WSAD 5.1 IDE with inbuilt Test environment WebSphere server
    JSF Version: Sun's RI 1.1
    Struts framework: 1.2.6
    Struts-Faces Integration Library version: 1.0
    I have configured a controller element in struts-config.xml file as has been suggested by different online
    documents I studied:
    <controller>
    <set-property property="processorClass"
    value="org.apache.struts.faces.application.FacesRequestProcessor"/>
    </controller>
    But configuring a controller does not allow my test server to start up properly and due to errors the ActionServlet also becomes unavailable.
    If I comment the controller and start the test server it starts fine but then I cannot access the converted jsf page which contains the <s:form action="/xxxxx.do"> tag.
    If now I get back to <h:form> tag instead of <s:form> tag with a <h:commandButton action="xxxx.do"/> for form submission in my jsf page, I see the html page generated with all components but now checking the html source generated I see
    <form action="/contextName/jspFolder/sameDisplayedPage.jsf"> which is not valid and never gets called successfully.
    I think someways I need to use the <s:form> tag with the controller configured properly to use the struts-faces integration library's request processor, to get things working. But HOW???
    Following is the error I get if I use the <controller> tag element in struts-config.xml file and start the server.
    This error appears on starting the server without accessing any application's jsp web page
    [6/12/06 15:31:14:109 IST] 3e311815 ActionServlet E org.apache.struts.action.ActionServlet Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable. Most likely, this is due to an incorrect or missing library dependency.
    [6/12/06 15:31:14:109 IST] 3e311815 ActionServlet E org.apache.struts.action.ActionServlet TRAS0014I: The following exception was logged java.lang.IllegalAccessError: org.apache.commons.digester.SetPropertyRule tried to access method org/apache/commons/beanutils/BeanUtils.setProperty(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V
    at org.apache.commons.digester.SetPropertyRule.begin(SetPropertyRule.java:198)
    at org.apache.commons.digester.Rule.begin(Rule.java:200)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1273)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digester.java:1548)
    at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:736)
    at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:685)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:331)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doInit(StrictServletInstance.java:82)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._init(StrictLifecycleServlet.java:147)
    at com.ibm.ws.webcontainer.servlet.PreInitializedServletState.init(StrictLifecycleServlet.java:270)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.init(StrictLifecycleServlet.java:113)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.init(ServletInstance.java:189)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:870)
    at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:224)
    at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
    at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
    at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
    at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
    at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
    at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:987)
    at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
    at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:418)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:787)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:575)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:271)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:249)
    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
    at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:125)
    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
    at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
    at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
    at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
    at java.lang.reflect.Method.invoke(Method.java:386)
    at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
    at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)
    [6/12/06 15:31:14:188 IST] 3e311815 WebGroup E SRVE0020E: [Servlet Error]-[ActionServlet]: Failed to load servlet: javax.servlet.UnavailableException: org.apache.commons.digester.SetPropertyRule tried to access method org/apache/commons/beanutils/BeanUtils.setProperty(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:366)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doInit(StrictServletInstance.java:82)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._init(StrictLifecycleServlet.java:147)
    at com.ibm.ws.webcontainer.servlet.PreInitializedServletState.init(StrictLifecycleServlet.java:270)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.init(StrictLifecycleServlet.java:113)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.init(ServletInstance.java:189)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:870)
    at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:224)
    at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
    at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
    at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
    at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
    at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
    at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:987)
    at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
    at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:418)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:787)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:575)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:271)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:249)
    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
    at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:125)
    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
    at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
    at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
    at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
    at java.lang.reflect.Method.invoke(Method.java:386)
    at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
    at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)
    (same error message re-iterates/repeats itself... and finally -
    Error 503: Failed to load target servlet [ActionServlet] comes in web-browser
    Following is the error which I get if I comment the <controller> element in the struts-config.xml file
    and use a <s:form action="xxxxx.do"> in the struts converted jsf page. The web-server starts fine, but
    accessing the jsf page givers error as:
    [6/12/06 15:38:00:781 IST] 696f19de WebGroup I SRVE0180I: [Sample Struts-JSF integration application] [training2] [Servlet.LOG]: /jsp/welcomeF.jsp: init
    [6/12/06 15:38:01:219 IST] 696f19de WebGroup E SRVE0026E: [Servlet Error]-[]: java.lang.NullPointerException
    at org.apache.struts.faces.renderer.FormRenderer.encodeBegin(FormRenderer.java:114)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683)
    at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:591)
    at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:478)
    at org.apache.jsp._welcomeF._jspService(_welcomeF.java:207)
    at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:662)
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
    at org.apache.struts.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1054)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:992)
    at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:551)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:209)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:412)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
    Finally if I change my <s:form action="xxxxx.do"> tag to
    <h:form>
    <h:commandButton id="submit" action="xxxx.do" value="Submit" />
    I see the webpage coming up in the browser (no controller element used in struts-config.xml file this time)
    But in the html source of this html created from jsf I see
    <form id="_id2" method="post" action="/training2/jsp/welcomeF.faces" enctype="application/x-www-form-urlencoded">
    here form's action attribute is pointing to the same displayed page with the context name prefixed. I
    assume it is because jsf could not resolve the "xxxx.do" action to anything so set it to the same displayed page.
    May be I am wrong as usual...
    Below is the simple struts jsp page which I need to convert to jsf page as I am converting only the View part of application.
    I want to use the same struts beans and application logic at the back-end. At front-end I need UIComponents from JSF to be used.
    Following is the struts jsp page
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
    <%@ taglib prefix="html" uri="/WEB-INF/lib/struts-html.tld" %>
    <%@ taglib prefix="bean" uri="/WEB-INF/lib/struts-bean.tld" %>
    <html:html>
    <html:base/>
    <html:messages id="messages" />
    <font style="color:red; font=weight:italic; font-family: century gothic">
    <html:errors/>
    </font>
    <BODY>
    <P>Sample Struts and JSF integration example</P>
    <P>This one is being displayed via Struts specific tags</P>
    <html:form action="validateUser.do">
    <bean:message key="label.name" /> : <html:text property="name" />
    <bean:message key="label.password" /> : <html:password property="password" />
    <bean:message key="label.age" /> : <html:text property="age" />
    <bean:message key="label.city" /> : <html:text property="city" />
    <bean:message key="label.address" /> : <html:text property="address" />
    <html:submit property="submit" value="Show info via Struts" />
    </html:form>
    </BODY>
    </html:html>
    I have converted it into the following jsf page
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://struts.apache.org/tags-faces" prefix="s" %>
    <f:view>
    <HTML><BODY>
    <f:verbatim><P>Sample Struts and JSF integration example</P></f:verbatim>
    <f:verbatim><P>This one is being displayed via JSF tags</P></f:verbatim>
    <h:form> <!-- Want to use s:form tag instead of this h:form tag -->
    <h:inputText id="name" value="#{userForm.name}" /><f:verbatim>
    </f:verbatim>
    <h:inputSecret id="password" value="#{userForm.password}" /><f:verbatim>
    </f:verbatim>
    <h:inputText id="age" value="#{userForm.age}" /><f:verbatim>
    </f:verbatim>
    <h:inputText id="city" value="#{userForm.city}" /><f:verbatim>
    </f:verbatim>
    <h:inputText id="address" value="#{userForm.address}" /><f:verbatim>
    </f:verbatim>
    <h:commandButton id="submit" action="#{user.facesAction}" value="Show info via Struts" />
    </h:form>
    </BODY></HTML>
    </f:view>
    I am very hopeful of some answer from respected group experts, please help me.
    I am in urgency of course but would not push for immed. response like other, just want some help for sure that is going to
    be extremely valuable to me. Anticipating a helping hand...
    Thanks and Regards
    Vishal Sharm
    Time's fun when you're having flies � Kermit, the Frog
    -------------------------------------------------------------------------

    I've managed to get this working Ok from JDeveloper:
    See:
    http://www.groundside.com/blog/content/DuncanMills/J2EE+Development/?permalink=573FDB6F8D918B9704907899635CABB1.txt
    http://www.groundside.com/blog/content/DuncanMills/J2EE+Development/?permalink=2B04ACE99A6437EDED775F15553D1DED.txt
    Basically you just have to fiddle around with Library settings to get this working OK.
    As to how useful this is, well that's up to you - I'd not regard Faces + Struts as a must use combination, rather it's a can mix if you really need to. Look at Faces and Faces navigation first and see if that actually gives you enough before you start to look at mixing.

  • Should we use struts? Or another framework?

    Hi all!
    The company I work at is building a set of java applications (internal tools) and a website (what the clients will use). So our internal tools' users are our employees, and clients will use the website. Anyways, small introduction to get you situated. Also we use an object oriented database system (very high tech stuff I love it) and a JDO mapping to it. Now we are at the stage where all our internal tools are built, and we need to build the website. We will not have MASSIVE traffic to it, the nature of our product is more likely to be used often by a few clients. Our website will have all the standard stuff, like login, my account, mailing list, forum, news feed, menues, and a billing process for our clients, so we need some security.
    All this to ask this simple question, given these parameters, do you think its a good thing for us to use Struts, or would we be ok with just jsp / servlets? For now, we have determined that using an application server is not necessary (we cant use EJB CMP because of JDO, and like I said we dont expect massive traffic), and we are looking for using templates also (Velocity looks good). The bottleneck for us is does it require a big learning curve, considering we are still newbies at jsp / servlets also. We would like to spend no more than 1 to 1 1/2 month to build the website.
    Thanks for your thoughts, sorry for long post :)

    The bottleneck
    for us is does it require a big learning curve,
    considering we are still newbies at jsp / servlets
    also. Struts definitely has a ramp up time -- especially if you are extensively using the taglibs that it comes with (and which provide most of it's power, in my opinion). If you are still ramping up on servlets and such, struts can free you from doing stuff that you would have to figure out for yourself. E.g.
    1. Proper handling of forms to provide validation and little detail things like repopulating them if something goes wrong
    2. Displaying messages back to the end user.
    3. Boring code to get html input from the user and put it into your object model.
    Personally, I think that struts makes it much easier to make robust and consistent applications, especially if multiple developers are working on a project. Also, since it is fairly well known, it's a lot easier to maintain/pickup an app written in struts rather than a custom job. Of course, that means that you don't have as much job security...;)
    So the question to you may be -- given what you know of what you need to do, what do you think will take longer -- building your own framework or learning one that has a fair amount of developer support. Of course everybody could do their own thing and you could spend a month mishmashing it to work together, which isn't unheard of either (although not recommended).
    ncuka

  • Loading Collections in to DropDownList box using Struts with bean

    Hi folks,
    I am very new to struts.
    I am developing one small web application using struts. I has developed Bussiness Logic, i need to use properly in struts.
    ManufacturerList.java is a Bussiness Logic class using to load all manufacturer from the database. It using by the collection LinkedHashMap.
    I need to use this BL in my struts application.
    GOAL: In sturts application i need to add the car details, one of the property for car is manufacturer.
    When creating the car, it should display all the manufacturer in the new student form.
    Please explain how to create with struts.
    Some of the Code i developed
    {color:#ff0000}<html:form action="/Car?op=saveCar">
    <html:errors/>
    <html:hidden property="op" value="saveCar"/>
    <html:hidden property="carCode"/>
    Car Name <html:text property="model"></html:text> <br>
    Manufacturer
    <!-- Defining the bean for manufacturer list getting from the request-->
    <bean:define id="mfrList" name="ManufacturerList" property="manufacturers"
    scope="request"
    type="java.util.Collection">
    </bean:define>
    <br>
    Manufacturer Year <html:text property="yearOfManufacture"></html:text><br>
    Date of Purchase <html:text property="dateOfPurchase"></html:text> <br>
    <html:submit value="Ok" />
    </html:form>{color}
    This is code is not working properly.... Please explain

    Hi i did like this
    {color:#0000ff}<bean:define id="mfrList" name="ManufacturerList" {color}
    {color:#0000ff}scope="request" {color}
    {color:#0000ff}type="com.icalib.trafficSimulator.ManufacturerList">{color}
    {color:#0000ff}</bean:define>{color}
    {color:#0000ff}<html:select property="make">{color}
    {color:#0000ff}<html:optionsCollection name="mfrList" label="mfrName" value="mfrCode"/>{color}
    {color:#0000ff}</html:select>{color}
    But the error is comming like thisjavax.servlet.ServletException: Cannot create iterator for 1:Honda
    2:Maruti
    3:Hyundai
    4:Toyota
    5:Accord
    6:Test_mfr
    7:test_mfr2
    8:456
    9:again
    10:123
    11:again1
    What to give in the label and value in the optionsCollection                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Error Handling in Struts

    Hi all,
    I am using Struts framework in one of my projects.
    How do i implement Error handling using global Exceptions of config file?
    Now i am using a different method. But Still i can't catch all the errors Properly.
    Is it possible to handle all types of errors using globalExceptions( including null pointer Exception)?
    Pls Sugst me.
    TanX
    AE

    Try using this...
    ActionErrors errors = new ActionErrors();
    errors.add("symbol",new ActionError("errors.lookup.unknown"));

  • Using Struts with Oracle

    Hi
    I need to use the struts framework with oracle (10g express edition), I am using eclipse IDE. anyone please help me. I dont know how to set these up for use..

    Struts doesn't define anything for the data access layer.
    It helps you write MVC applications, and provides a translator between your view (jsp pages) and your model (action forms/actions), but once you get to that point its all standard java code.
    You have a few alternatives
    1 - write java classes to handle the data access layer: Data Access Objects (or DAOs) using standard java/jdbc.
    2 - Use a tool like hibernate to do your data layer handling.
    Struts itself though won't help at all with this.

  • Collection in collection using Struts

    I know we can submit the value of value object in collection using the following code.
    <logic:iterate id="collection" name="form" property="collection">
    <html:hidden indexed="true" name="collection" property="code" />
    </logic:iterate>
    But how about collection in collection? Is this possible in struts?
    Thanks in advance

    What you say is indeed the way to use struts.
    But I dont want to define in my jsp which fields of the Company object I want to display. I just want to loop through array of Collections and display them on my screen.
    I would like to ask the EJB for example getCompanyByName which returns me a array of Collections : (Company a, street 1) , (Company b, street 2)
    If I call getCompanyByStreet it returns me (street 1, Company a), (street 2, Company b)
    Thanks
    Nathalie

  • Running  a webApplication using struts

    Hi forum,
    I am using struts & in index.jsp I have used following lines of code
    <code>
    <html:form action="Lookup" name="lookupForm" type="Project.LookupForm" >
    <table width="45%" border="0">
    <tr><td>Symbol:</td>
    <td><html:text property="symbol" /></td>          
    </tr>
    <tr><td><html:submit /></td></tr>
    </table>
    </html:form>
    </code>
    It is giving org.apache.jasper.JasperException: /index.jsp(11,2) Attribute name invalid for tag form according to TLD
    When I observed the struts-html.tld there was no 'name' or type attribute under form tag.
    What is the reason behind it & how can I get rid off it.
    Thanks

    Remove the "name" and "type" attributes from the html:form tag
    You don't specify them here, but rather in the struts-config.xml.
    In an early version of struts I think these attributes were valid, but not for quite a while now.
    <html:form action="Lookup">

  • Using struts-faces : can't find "forward".

    using struts-faces : can't find "forward".
    I download the struts-faces lib and want to make a integration with struts && JSF.
    The action's one method is executed, but after that, it can't find the forward page.
    The console display:
    // Here is the initLogon() method of LogonAction, just print 2 message
    [LogonAction] DEBUG: initLogon start
    [LogonAction] DEBUG: initLogon end
    // Then output these:
    [FacesRequestProcessor] DEBUG: Standard action perform returned /index.faces forward path
    [FacesRequestProcessor] DEBUG: Performing standard forward config handling
    [RequestProcessor] DEBUG: processForwardConfig(ForwardConfig[name=logon_page,path=/index.faces,redirect=false,contextRelative=false])
    [FacesRequestProcessor] DEBUG: doForward(/index.faces)
    // Then exception occured:
    <[ServletContext(id=19306074,name=/interactive,context-path=/interactive)]
    Servlet failed with Exception
    java.lang.NullPointerException
            at org.apache.struts.faces.application.FacesRequestProcessor.doForward(FacesRequestProcessor.java:121)
            ......Here is part of my config file, maybe the exception was caused by something I missed
    In struts-config.xml:
         <action-mappings>
              <action path="/LogonAction"
                   type="org.interactive.interactive.presentation.security.LogonAction"
                   scope="request"
                   name="LogonForm"
                   parameter="method"
                   input="/LogonAction.do?method=initLogon"
                   validate="false">
                   <forward name="logon_page" path="/index.faces"/>
              </action>
         </action-mappings>     In web.xml:
         <servlet>
              <servlet-name>faces</servlet-name>
              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
         </servlet>
             <servlet-mapping>
                    <servlet-name>faces</servlet-name>
                    <url-pattern>*.faces</url-pattern>
             </servlet-mapping>           In faces-config.xml, I left it empty:
         <faces-config>
         </faces-config>           The index.jsp is very simple:
         it just include a string "This is index.jsp", no any tag.
    Please give me some advice, thanks !

    Need Help!
    I use weblogic8.1 and
    the entry is http://localhost:7001/interactive/LogonAction.do?method=initLogon
    I don't know why it execute the initLogon() method but can't return to the page.

  • Using Struts or Spring dilemma?

    HI all,
    just a query , if we want to create a huge application having around 100's of Enterprise Beans and JSP pages around 1000, which Framework one should choose or go for between Struts and Spring. I have worked on Struts it seems to be popular choice and stable. But don't even have a vague notion about Spring Framework.
    Wherein the application demands stability and performance enhancement.
    Avadhoot.

    Struts and Spring are two seperate frameworks , one can be used to implement View lyer using MVC and the other can contain all aspect of your application from the view to business and back end connection.
    you can use Struts with spring , int this scenario struts will be the View layer and spring framework will handle other stuff like DA , Mailing , Transaction , Secrity ,....
    I can say that :
    go with EJB for Business layer , Use struts for View
    and use netbeans 5 as IDE , it made developing ejb stuff too easy.

Maybe you are looking for