BeanUtils populate

Hi,
I am populating a bean in a servlet from request parameters using the BeanUtils.populate method.
This works fine mostly. The problem i am having is getting it to populate nested beans?
Example.
public User setUser(User u){
user = u;
the way i am populating is like this
HashMap map = new HashMap();
Enumeration names = request.getParameterNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
map.put(name, request.getParameterValues(name));
BeanUtils.populate(bean, map);
Thanks for anyones help.
Paul

Hi,
I am populating a bean in a servlet from request parameters using the BeanUtils.populate method.
This works fine mostly. The problem i am having is getting it to populate nested beans?
Example.
public User setUser(User u){
user = u;
the way i am populating is like this
HashMap map = new HashMap();
Enumeration names = request.getParameterNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
map.put(name, request.getParameterValues(name));
BeanUtils.populate(bean, map);
Thanks for anyones help.
Paul

Similar Messages

  • BeanUtils.populate exception (Need Help)

    Dear All,
    Am getting a strange exception when try to do a action in struts, below is my exception, please help me in solving this issue.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: BeanUtils.populate
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1190)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
         java.security.AccessController.doPrivileged(Native Method)
         java.security.AccessController.doPrivileged(Native Method)
         org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
    root cause
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
         java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
         java.security.AccessController.checkPermission(AccessController.java:427)
         java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1662)
         java.lang.Class.checkMemberAccess(Class.java:2125)
         java.lang.Class.getDeclaredMethods(Class.java:1762)
         org.apache.commons.beanutils.MappedPropertyDescriptor$1.run(MappedPropertyDescriptor.java:386)
         java.security.AccessController.doPrivileged(Native Method)
         org.apache.commons.beanutils.MappedPropertyDescriptor.getPublicDeclaredMethods(MappedPropertyDescriptor.java:383)
         org.apache.commons.beanutils.MappedPropertyDescriptor.internalFindMethod(MappedPropertyDescriptor.java:453)
         org.apache.commons.beanutils.MappedPropertyDescriptor.findMethod(MappedPropertyDescriptor.java:527)
         org.apache.commons.beanutils.MappedPropertyDescriptor.<init>(MappedPropertyDescriptor.java:149)
         org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:865)
         org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:991)
         org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:865)
         org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:343)
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1188)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
         java.security.AccessController.doPrivileged(Native Method)
         java.security.AccessController.doPrivileged(Native Method)
         org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.Thanks in advance,
    vyrav.

    Thanks for ur reply Ganesh.
    This is my JSP
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html:html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Uploaded File Details</title>
         <script>
              function logOut()
                        document.adminForm.action="upload.do?parameter=logout";
                        document.adminForm.submit();
              function download(temp)
                        document.adminForm.fileId.value = temp;
                        document.adminForm.action="download.do";
                        document.adminForm.submit();
         </script>
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
         <table align="right">
                        <tr>
                             <td>
                                  <a href="javascript:logOut();">Logout</a>
                             </td>
                        </tr>
         </table>
         <%
                        if(session.getAttribute("name")!=null)
                                    String userName= (String) session.getAttribute("name");
         %>
                   <br /><br /><b>Welcome <%=userName%></b><br />
         <%
         %>
         <center>
              <html:form action="/download.do" name="adminForm" type="com.roots.AdminForm">
                   <br /><br />
                   <html:hidden property="fileId"/>
                   <table align="center" border="1">
                        <tr bgcolor="#FFCC66">
                             <td align="center">
                                  No
                             </td>
                             <td align="center">
                                  Name
                             </td>
                             <td align="center">
                                  Uploaded Date
                             </td>
                             <td align="center">
                                  File Name
                             </td>
                        </tr>
                        <logic:iterate name="adminForm" property="displayList" id="displayDto">
                             <tr>
                                  <td align="center">
                                       <bean:write name="displayDto" property="serialNo"/>
                                  </td>
                                  <td align="left">
                                       <bean:write name="displayDto" property="empName"/>
                                  </td>
                                  <td align="left">
                                       <bean:write name="displayDto" property="uploadedDate"/>
                                  </td>
                                  <td align="left">
                                       <a href="javascript:download('<bean:write name="displayDto" property="serialNo"/>');"><bean:write name="displayDto" property="fileName"/></a>
                                  </td>
                             </tr>
                        </logic:iterate>
                   </table>
              </html:form>          
         </center>
    </body>
    </html:html>This is my struts config
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
             "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
             "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
         <struts-config>
               <data-sources>
               </data-sources>
              <form-beans>
                   <form-bean name="loginForm" type="com.roots.LoginForm" />
                   <form-bean name="uploadForm" type="com.roots.UploadForm" />
                   <form-bean name="adminForm" type="com.roots.AdminForm" />
              </form-beans>
              <global-forwards></global-forwards>
              <action-mappings>
                   <action path="/login"
                        name="loginForm"
                        scope="request"
                        validate="true"
                        input="/login.jsp"
                        type="com.roots.LoginAction" >
                             <forward name="SUCCESS" path="/upload.jsp" />
                             <forward name="FAILURE" path="/login.jsp" />
                             <forward name="ADMIN" path="/admin.do" />
                   </action>
                   <action path="/upload"
                        name="uploadForm"
                        scope="request"
                        parameter="parameter"
                        input="/upload.jsp"
                        type="com.roots.UploadAction" >
                             <forward name="SUCCESS" path="/upload.jsp" />
                             <forward name="FAILURE" path="/login.jsp" />
                   </action>
                   <action path="/download"
                             type="com.roots.FileDownloadAction">
                   </action>
                   <action path="/admin"
                        name="adminForm"
                        scope="request"
                        validate="false"
                        type="com.roots.AdminAction" >
                        <forward name="DISPLAY" path="/admin.jsp" />
                        <forward name="FAILURE" path="/login.jsp" />
                   </action>
              </action-mappings>
              <message-resources parameter="application_fr"/>
            <message-resources parameter="application_es"/>
            <message-resources parameter="application_en"/>
            <message-resources parameter="application_de"/>
            <message-resources parameter="application" />
         </struts-config>this is my form package com.roots;
    import java.util.List;
    import org.apache.struts.action.ActionForm;
    public class AdminForm extends ActionForm {
         private List displayList = null;
         public String fileId;
         public String getFileId() {
              return fileId;
         public void setFileId(String fileId) {
              this.fileId = fileId;
         public List getDisplayList() {
              return displayList;
         public void setDisplayList(List displayList) {
              this.displayList = displayList;
    }Please let me know wat am doing wrong, this is killing me for the last two days.
    Thanks,
    vyrav.

  • BeanUtils.Populate() servletException

    Will anyone tell me why this error is coming.
    I am using it in struts programming, (In this program i'm using validator.xml also but that is working but when it goes to form action it is showing error)i had imported the beanutils.jar files also but i'm not able to track the error so if anyone knows the answer please reply. Thanks for helping in advance...
    Rose.

    Thank you very much. Four years later and that advice still helped me.
    You are probably missing an 'enctype' attribute on
    your <html:form> tag. Try this:
    <html:form ... enctype="multipart/form-data">
    ou must use multipart/form-data when using upload
    fields. If not, you will get the BeanUtils.populate()
    exception when you submit the form.

  • Javax.servlet.ServletException: BeanUtils.populate

    hi all,
    anyone know why this error is coming
    thnx

    I have got the below exception while using multipart form data in struts.
    javax.servlet.ServletException: BeanUtils.populate
    at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
    at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:805)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
    at java.lang.Thread.run(Thread.java:534)

  • Got error when trying to populate JSP from ActionServlet......Help me

    Hi Guys,
    In My application, I need to search a directory on my machine like if i give abc, it should display all files that match "abc". For that i have a Jsp page which accepts the pattern and am using MVC architecture for developing this application and I got this error when i ran the application. My jsp page:
    <body>
    <html:form action="/searchPattern">
    <TABLE border="0">
    <TBODY>     <TR>
         <TH>File Pattern</TH>
         <TD><html:text property="pattern" /></TD></TR>          <TR><TD><html:submit property="submit" value="Submit" /></TD></TR>
    </TBODY>
    </TABLE>
    </html:form>
    </body>
    another Jsp for displaying the results:
    <body>
    <jsp:useBean class="com.mot.struts.form.SearchForm" id="fileDetail" scope="session"/>
    <table>     
    <tr><td>File Names</td>
         <td><jsp:getProperty name="fileDetail" property="pattern"/></td>
         <td><ul>
         <logic:iterate name="fileDetail" property="listFiles"
         id="fileDetails" scope="session">               
         <li><bean:write name="fileDetails" property="listFiles" />
         </li>                
         </logic:iterate>
         </ul></td>
         </tr>
    </table>
    </body>
    and the Action servlet is:
    public ActionForward execute(ActionMapping mapping, ActionForm form,
                   HttpServletRequest request, HttpServletResponse response) {
         SearchForm searchForm = (SearchForm) form;
    String pattern=request.getParameter("pattern");
    File dir = new File("D:\\satish\\archive");
    System.out.println("Searching....");               
    File[] children=dir.listFiles();
    for (int i=0; i<children.length; i++) {
    String fileMatch=children.getAbsoluteFile().getName();
    if(fileMatch.contains(pattern)==true){      
    System.out.println("File pattern with .log found, File Name "+ fileMatch);
              request.setAttribute("fileDetail", searchForm);           
    return mapping.findForward("success");
    else{
    System.out.println("File pattern does not found");
    return mapping.findForward("failure");
    and the FormBean is:
    public class SearchForm extends ActionForm {
         private List pattern;
         private List fileName;
         private List listFiles;
         public SearchForm(){          
         public SearchForm(List pattern, List fileName, List listFiles){
              this.pattern=pattern;
              this.fileName=fileName;
              this.listFiles=listFiles;
         public static class Files{          
         private Object fName;
         public Files(){               
         public Files(Object fName){               
         this.fName=fName;
         public Object getFName() {
         return fName;
         public void setFName(Object name) {
         fName = name;
         public List getListFiles() {
         int size=pattern.size();
         List listFiles=new ArrayList(size);
    for( int p = 0; p < size; p++ ) {
         listFiles.add(new Files(fileName.get(p)));
         return listFiles;
         public void setListFiles(List listFiles) {
              this.listFiles = listFiles;
         public List getPattern() {
              return pattern;
         public void setPattern(List pattern) {
              this.pattern = pattern;
         public List getFileName() {
              return fileName;
         public void setFileName(List fileName) {
              this.fileName = fileName;
    and I got the following error:
    javax.servlet.ServletException: BeanUtils.populate
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
    .........root cause:
    java.lang.IllegalArgumentException: argument type mismatch
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Plz help me in solving this

    your form bean probably has a property that was declared using the wrong data type

  • Action works on fireFox, BeanUtils error on IE ?!?!?!

    Hi there,
    I have a simple form that works greate on fireFox, but when trying the application on IE - I get this message:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: BeanUtils.populate
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.IllegalArgumentException: No bean specified
         org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)
         org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:937)
         org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
         org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.The action in the jsp looks like this:
              <td>
                   <html:image property="proposal.action" value="insert"
                               src="./images/submit.png" />
                                    <br><fmt:message key="button.group.proposal.submit"/>                         
              </td>     does anyone know why it works on fireFox but not on IE?
    thank you

    It is probably a feature of the input type="image" component.
    When submitting this component, it will pass in two request parameters - the x,y co-ordinates of where the image was clicked.
    ie <input type="image" name="proposal.action"
    will submit parameters proposal.action.x=??? and proposal.action.y=???
    In Firefox, it also submits proposal.action=insert (ie the value of the button) IE does not do this.
    That is probably the root cause of the issue.
    Struts does provide the [url http://struts.apache.org/1.2.9/api/org/apache/struts/util/ImageButtonBean.html] ImageButtonBean to use on your action form and determine if a button was clicked. However each individual button would have to have its own name - you can't use it with the DispatchAction so easily.

  • Request.getParameter("blah") from within a class?

    Hi Everyone,
    Not sure if I'm missing something...
    I'm trying to create a class that will examine and parse information from a form, and then pass it to another class that knows how to handle the input.
    A request in the form of http://www.domain.com/stuff.jsp?1=param1&2=param2&4=param4
    stuff.jsp only has this:
    UrlRequestGetter params = new UrlRequestGetter();
    out.println(params.getTheParams());and the general idea for the UrlRequestGetter class is this:
    public classUrlRequestGetter {
         public String getTheParams(){
              String request1 = request.getParameter("1");
                    String request2 = request.getParameter("2");
                    String request3 = request.getParameter("3");
                    String request4 = request.getParameter("4");
    }Within that class, there will be various actions to check whether or not fields are empty, etc. The big point is that i'm trying to do a request.getparameter from within a class. When i try to compile, I get:
    cannot find symbol
    symbol:variable request
    Any thoughts?
    Thanks!

    Take a step back from all that, and read the error message: cannot find symbol: symbol:variable request
    Is "request" a variable you have declared or passed into your method getTheParams() ?
    Where is it supposed to get the request from?
    "request" is an implicit variable to your JSP. If you want to use it in your bean, you have to pass it as a parameter.
    I'm trying to create a class that will examine and parse information from a form, and then pass it to another class that knows how to handle the input.You might consider using the <jsp:setProperty> tag to map parameters to bean attributes automagically.
    Or the BeanUtils.populate method provided by Jakarta Commons BeanUtils.
    Or any framework like struts, jsf, spring, stripes....
    Cheers,
    evnafets

  • Error while running application with Tomcat 5.0

    Hi,
    I am trying to run my application on Tomcat 5.0. I have java environment version 1.4
    I am getting the following error during the server start up :
    Mar 30, 2007 3:51:03 PM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Mar 30, 2007 3:51:03 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 1047 ms
    Mar 30, 2007 3:51:03 PM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Mar 30, 2007 3:51:03 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.0.28
    Mar 30, 2007 3:51:03 PM org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    Mar 30, 2007 3:51:03 PM org.apache.catalina.core.StandardHost
    getDeployer
    INFO: Create Host deployer for direct deployment ( non-jmx )
    Mar 30, 2007 3:51:03 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Processing Context configuration file URL file:C:\Program
    Files\Apache Sof
    tware Foundation\Tomcat 5.0\conf\Catalina\localhost\admin.xml
    Mar 30, 2007 3:51:04 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing, config='org.apache.struts.util.LocalStrings',
    returnNull=tru
    e
    Mar 30, 2007 3:51:04 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing, config='org.apache.struts.action.ActionResources',
    returnNul
    l=true
    Mar 30, 2007 3:51:05 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing,
    config='org.apache.webapp.admin.ApplicationResources', retur
    nNull=true
    Mar 30, 2007 3:51:06 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Processing Context configuration file URL file:C:\Program
    Files\Apache Sof
    tware Foundation\Tomcat 5.0\conf\Catalina\localhost\balancer.xml
    Mar 30, 2007 3:51:07 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Processing Context configuration file URL file:C:\Program
    Files\Apache Sof
    tware Foundation\Tomcat 5.0\conf\Catalina\localhost\manager.xml
    Mar 30, 2007 3:51:07 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Installing web application at context path /jsp-examples from URL
    file:C:\
    Program Files\Apache Software Foundation\Tomcat 5.0\webapps\jsp-examples
    Mar 30, 2007 3:51:07 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Installing web application at context path from URL
    file:C:\Program Files
    \Apache Software Foundation\Tomcat 5.0\webapps\ROOT
    Mar 30, 2007 3:51:07 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Installing web application at context path /servlets-examples from
    URL fil
    e:C:\Program Files\Apache Software Foundation\Tomcat
    5.0\webapps\servlets-exampl
    es
    Mar 30, 2007 3:51:07 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Installing web application at context path /tomcat-docs from URL
    file:C:\P
    rogram Files\Apache Software Foundation\Tomcat 5.0\webapps\tomcat-docs
    Mar 30, 2007 3:51:07 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Installing web application at context path /webdav from URL
    file:C:\Progra
    m Files\Apache Software Foundation\Tomcat 5.0\webapps\webdav
    Mar 30, 2007 3:51:07 PM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    Mar 30, 2007 3:51:07 PM org.apache.jk.common.ChannelSocket init
    INFO: JK2: ajp13 listening on /0.0.0.0:8009
    Mar 30, 2007 3:51:07 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/31 config=C:\Program Files\Apache Software
    Foundat
    ion\Tomcat 5.0\conf\jk2.properties
    Mar 30, 2007 3:51:08 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 4266 ms
    Mar 30, 2007 3:53:07 PM org.apache.catalina.core.StandardHostDeployer
    install
    INFO: Installing web application at context path /Hyperceller from URL
    file:C:\P
    rogram Files\Apache Software Foundation\Tomcat 5.0\webapps\Hyperceller
    Mar 30, 2007 3:53:08 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing, config='org.apache.struts.util.LocalStrings',
    returnNull=tru
    e
    Mar 30, 2007 3:53:08 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing, config='org.apache.struts.action.ActionResources',
    returnNul
    l=true
    Mar 30, 2007 3:53:09 PM org.apache.commons.digester.Digester
    startElement
    SEVERE: Begin event threw exception
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at
    org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(Property
    Utils.java:1656)
    at
    org.apache.commons.beanutils.PropertyUtils.setNestedProperty(Property
    Utils.java:1551)
    at
    org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.
    java:1580)
    at
    org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:919
    at
    org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
    at
    org.apache.commons.digester.SetPropertiesRule.begin(SetPropertiesRule
    .java:251)
    at org.apache.commons.digester.Rule.begin(Rule.java:152)
    at
    org.apache.commons.digester.Digester.startElement(Digester.java:1361)
    at
    org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Sour
    ce)
    at
    org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unkn
    own Source)
    at
    org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Sourc
    e)
    at
    org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
    own Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
    known Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
    Source)
    at org.apache.xerces.parsers.XML11Configuration.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:1647)
    at
    org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionSe
    rvlet.java:1006)
    at
    org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet
    .java:955)
    at
    org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
    at javax.servlet.GenericServlet.init(GenericServlet.java:211)
    at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
    java:1029)
    at
    org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:86
    2)
    at
    org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
    t.java:4013)
    at
    org.apache.catalina.core.StandardContext.start(StandardContext.java:4
    357)
    at
    org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:823)
    at
    org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80
    7)
    at
    org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
    at
    org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep
    loyer.java:277)
    at
    org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
    at
    org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
    ava:701)
    at
    org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432
    at
    org.apache.catalina.startup.HostConfig.check(HostConfig.java:1083)
    at
    org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
    :327)
    at
    org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
    at
    org.apache.catalina.core.StandardHost.backgroundProcess(StandardHost.
    java:800)
    at
    org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
    rocessChildren(ContainerBase.java:1619)
    at
    org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
    rocessChildren(ContainerBase.java:1628)
    at
    org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.r
    un(ContainerBase.java:1608)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.UnsupportedClassVersionError:
    com/hyperceller/form/LoginFor
    m (Unsupported major.minor version 49.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
    at
    java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    3)
    at
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(Webapp
    ClassLoader.java:1634)
    at
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoa
    der.java:860)
    at
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
    der.java:1307)
    at
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
    der.java:1189)
    at
    org.apache.struts.config.FormBeanConfig.formBeanClass(FormBeanConfig.
    java:320)
    at
    org.apache.struts.config.FormBeanConfig.setType(FormBeanConfig.java:1
    91)
    ... 46 more
    Mar 30, 2007 3:53:09 PM org.apache.struts.action.ActionServlet
    handleConfigExcep
    tion
    SEVERE: Parsing error processing resource path
    java.lang.reflect.InvocationTargetException
    at
    org.apache.commons.digester.Digester.createSAXException(Digester.java
    :2919)
    at
    org.apache.commons.digester.Digester.createSAXException(Digester.java
    :2945)
    at
    org.apache.commons.digester.Digester.startElement(Digester.java:1364)
    at
    org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Sour
    ce)
    at
    org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unkn
    own Source)
    at
    org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Sourc
    e)
    at
    org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
    own Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
    known Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
    Source)
    at org.apache.xerces.parsers.XML11Configuration.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:1647)
    at
    org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionSe
    rvlet.java:1006)
    at
    org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet
    .java:955)
    at
    org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
    at javax.servlet.GenericServlet.init(GenericServlet.java:211)
    at
    org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
    java:1029)
    at
    org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:86
    2)
    at
    org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
    t.java:4013)
    at
    org.apache.catalina.core.StandardContext.start(StandardContext.java:4
    357)
    at
    org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:823)
    at
    org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80
    7)
    at
    org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
    at
    org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep
    loyer.java:277)
    at
    org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
    at
    org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
    ava:701)
    at
    org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432
    at
    org.apache.catalina.startup.HostConfig.check(HostConfig.java:1083)
    at
    org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
    :327)
    at
    org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
    at
    org.apache.catalina.core.StandardHost.backgroundProcess(StandardHost.
    java:800)
    at
    org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
    rocessChildren(ContainerBase.java:1619)
    at
    org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
    rocessChildren(ContainerBase.java:1628)
    at
    org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.r
    un(ContainerBase.java:1608)
    at java.lang.Thread.run(Thread.java:534)
    Mar 30, 2007 3:53:44 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings',
    returnN
    ull=true
    Mar 30, 2007 3:53:44 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing, config='org.apache.struts.util.LocalStrings',
    returnNull=tru
    e
    Mar 30, 2007 3:53:44 PM org.apache.struts.util.PropertyMessageResources
    <init>
    INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings',
    returnN
    ull=true
    could anyone tell me what the problem may be???
    Note: When I configure my application on the Tomcat 5.5 and java 1.5 then it runs fine. But the problem arises when I compile my code on the java 1.4 and run on the Tomcat 5.0
    Thanks in advance!!

    I am sorry that I forgot to tell you that I am running a struts application. Struts 1.1

  • Struts : creation of new row problem.

    I have a problem with creation of a new row, using struts.
    I've created simple struts browse-edit page. From browse page I go to 'edit-new' page. My object have a primary key - ID. I'm initializing it from sequence in create() method after call to super.create().
    So, when I'm forwared to 'edit-new' form from 'browse' form new row created with id taken from sequence. When I go back to 'browse' form by 'update' action it looks that another row created in View object (and onother ID is taken from sequence). Then, if I have right understanding of how it works, all attributes from first created row are copied to the second row. When ID is copied, I've got
    java.lang.reflect.InvocationTargetException: oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key[22 ].
         oracle.jbo.server.EntityImpl oracle.jbo.server.EntityCache.add(oracle.jbo.server.EntityImpl)
              EntityCache.java:361
         void oracle.jbo.server.EntityCache.replace(oracle.jbo.server.EntityImpl, oracle.jbo.Key)
              EntityCache.java:631
         void oracle.jbo.server.EntityImpl.setAttributeValueInternal(int, java.lang.Object)
              EntityImpl.java:2048
         void oracle.jbo.server.EntityImpl.setAttributeValue(int, java.lang.Object)
              EntityImpl.java:1844
         void oracle.jbo.server.AttributeDefImpl.set(oracle.jbo.Row, java.lang.Object)
              AttributeDefImpl.java:1688
         void oracle.jbo.server.EntityImpl.setAttributeInternal(int, java.lang.Object)
              EntityImpl.java:823
         void cern.ppt.lhc.evm.struts.UnitConversionsImpl.setId(oracle.jbo.domain.Number)
              UnitConversionsImpl.java:69
         void cern.ppt.lhc.evm.struts.UnitConversionsImpl.setAttrInvokeAccessor(int, java.lang.Object, oracle.jbo.server.AttributeDefImpl)
              UnitConversionsImpl.java:154
         void oracle.jbo.server.EntityImpl.setAttribute(int, java.lang.Object)
              EntityImpl.java:750
         void oracle.jbo.server.ViewRowStorage.setAttributeValue(int, java.lang.Object)
              ViewRowStorage.java:913
         void oracle.jbo.server.ViewRowStorage.setAttributeInternal(int, java.lang.Object)
              ViewRowStorage.java:829
         void oracle.jbo.server.ViewRowImpl.setAttributeInternal(int, java.lang.Object)
              ViewRowImpl.java:984
         void oracle.jbo.server.ViewRowImpl.setAttrInvokeAccessor(int, java.lang.Object, oracle.jbo.server.AttributeDefImpl)
              ViewRowImpl.java:961
         void oracle.jbo.server.ViewRowImpl.setAttribute(int, java.lang.Object)
              ViewRowImpl.java:753
         void oracle.jbo.html.struts11.BC4JActionForm.setAttribute(oracle.jbo.AttributeDef, java.lang.Object)
              BC4JActionForm.java:91
         void oracle.jbo.html.struts11.BC4JActionForm.setAttribute(java.lang.String, java.lang.Object)
              BC4JActionForm.java:103
         void cern.ppt.lhc.evm.struts.UnitConversionsViewForm.setId(java.lang.Object)
              UnitConversionsViewForm.java:18
         java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])
              native code
         void org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(java.lang.Object, java.lang.String, java.lang.Object)
              PropertyUtils.java:1650
         void org.apache.commons.beanutils.PropertyUtils.setNestedProperty(java.lang.Object, java.lang.String, java.lang.Object)
              PropertyUtils.java:1545
         void org.apache.commons.beanutils.PropertyUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object)
              PropertyUtils.java:1574
         void org.apache.commons.beanutils.BeanUtils.setProperty(java.lang.Object, java.lang.String, java.lang.Object)
              BeanUtils.java:919
         void org.apache.commons.beanutils.BeanUtils.populate(java.lang.Object, java.util.Map)
              BeanUtils.java:726
         void oracle.jbo.html.struts11.MultipartUtil._populate(java.lang.Object, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest)
              MultipartUtil.java:194
         void oracle.jbo.html.struts11.BC4JRequestProcessor.processPopulate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.struts.action.ActionForm, org.apache.struts.action.ActionMapping)
              BC4JRequestProcessor.java:417
         void org.apache.struts.action.RequestProcessor.process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
              RequestProcessor.java:246
         void org.apache.struts.action.ActionServlet.process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
              ActionServlet.java:1292
         void org.apache.struts.action.ActionServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
              ActionServlet.java:510
         void javax.servlet.http.HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
              HttpServlet.java:760
         void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
              HttpServlet.java:853
         void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
              ServletRequestDispatcher.java:724
         void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse)
              ServletRequestDispatcher.java:309
         boolean com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.ApplicationServerThread, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletRequest, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
              HttpRequestHandler.java:767
         void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(java.lang.Thread)
              HttpRequestHandler.java:259
         void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run()
              HttpRequestHandler.java:106
         void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
              PooledExecutor.java:803
         void java.lang.Thread.run()
              Thread.java:484
    If I switch off filleng ID from the sequence everething works. It looks, that it fails, when It's coping ID (it gets two rows with the same ID).
    So, my question is - why two rows creating? And is there a way how to solve this problem, without switching off filling ID from a sequence (I really need this)?

    After reading this I am not sure what the solution is.
    I've created a VO that contains 2 EO's that are using sequence and NO trigger. I've tested this in the app module testor and it works. After using the Wizard to build a Struts/BC4J app I get the following when pressing "update" after creating a new record - "JBO-25013: Too many objects match the primary key oracle.jbo.Key[279 ]".
    Charles Gayraud suggested changing the method that sets the PK but I'm not sure what to change as there are 2 sections that deal with setting the PK, neither of which match the methods in Charles suggestion. see below
    So what is the solution here?
    Thanks,
    Bill G...
    public void setParentId(Number value) {
    setAttributeInternal(PARENTID, value);
    and
    // BG ADD
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("S_PARENT", getDBTransaction());
    setAttribute("ParentId", s.getSequenceNumber());
    // ParentImpl.java FULL LISTING
    package mypackage27;
    import oracle.jbo.AttributeList;
    import oracle.jbo.Key;
    import oracle.jbo.RowIterator;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.AttributeDefImpl;
    import oracle.jbo.server.EntityDefImpl;
    import oracle.jbo.server.EntityImpl;
    // bg add
    import oracle.jbo.server.SequenceImpl;
    // --- File generated by Oracle Business Components for Java.
    public class ParentImpl extends EntityImpl {
    protected static final int PARENTID = 0;
    protected static final int PARENTDESC = 1;
    protected static final int CHILD = 2;
    private static EntityDefImpl mDefinitionObject;
    * This is the default constructor (do not remove)
    public ParentImpl() {
    * Retrieves the definition object for this instance class.
    public static synchronized EntityDefImpl getDefinitionObject() {
    if (mDefinitionObject == null) {
    mDefinitionObject = (EntityDefImpl) EntityDefImpl.findDefObject(
    "mypackage27.Parent");
    return mDefinitionObject;
    * Gets the attribute value for ParentId, using the alias name ParentId
    public Number getParentId() {
    return (Number) getAttributeInternal(PARENTID);
    * Sets <code>value</code> as the attribute value for ParentId
    public void setParentId(Number value) {
    setAttributeInternal(PARENTID, value);
    * Gets the attribute value for ParentDesc, using the alias name ParentDesc
    public String getParentDesc() {
    return (String) getAttributeInternal(PARENTDESC);
    * Sets <code>value</code> as the attribute value for ParentDesc
    public void setParentDesc(String value) {
    setAttributeInternal(PARENTDESC, value);
    // Generated method. Do not modify.
    protected Object getAttrInvokeAccessor(int index, AttributeDefImpl attrDef)
    throws Exception {
    switch (index) {
    case PARENTID:return getParentId();
    case PARENTDESC:return getParentDesc();
    case CHILD:return getChild();
    default:return super.getAttrInvokeAccessor(index, attrDef);
    // Generated method. Do not modify.
    protected void setAttrInvokeAccessor(int index, Object value,
    AttributeDefImpl attrDef) throws Exception {
    switch (index) {
    case PARENTID:setParentId((Number) value);
    return;
    case PARENTDESC:setParentDesc((String) value);
    return;
    default:super.setAttrInvokeAccessor(index, value, attrDef);
    return;
    * Gets the associated entity oracle.jbo.RowIterator
    public RowIterator getChild() {
    return (RowIterator) getAttributeInternal(CHILD);
    * Creates a Key object based on given key constituents
    public static Key createPrimaryKey(Number parentId) {
    return new Key(new Object[] { parentId });
    // BG ADD
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("S_PARENT", getDBTransaction());
    setAttribute("ParentId", s.getSequenceNumber());

  • Unable to retrive the uploaded file in Struts

    hi i am getting error while retrieving the uploaded file in struts. The code is
    struts-config.xml
    ===========
    <form-bean name="GreivanceForm" type="org.apache.struts.validator.DynaValidatorActionForm" >
                   <form-property name="compcode" type="java.lang.String" />
                   <form-property name="complaintName" type="java.lang.String" />
                   <form-property name="category" type="java.lang.String" />
                   <form-property name="subcategory" type="java.lang.String" />
                   <form-property name="priority" type="java.lang.String" />
                   <form-property name="occdate" type="java.lang.String" />
                   <form-property name="occtime" type="java.lang.String" />
                   <form-property name="desc" type="java.lang.String" />
                   <form-property name="comments" type="java.lang.String" />
                   <form-property name="onbehalf" type="java.lang.String"/>
                   <form-property name="employeeId" type="java.lang.String"/>
                   <form-property name="hidSelectedNames" type="java.lang.String"/>
                   <form-property name="individual" type="java.lang.String"/>
                   <form-property name="compOption" type="java.lang.String" />
                   <form-property name="selectedrequestor" type="java.lang.String" />
                   <form-property name="file" type="java.lang.String"/>
              </form-bean>
    <action path="/helpdesk/GrievanceComplaint"
                   type="com.srit.hrnet.helpdesk.grievancemechanism.GrievanceComplaintAction"
                   scope="request" name="GreivanceForm"
                   input=""
                   validate="true"
                   parameter="compOption" >
                   <forward name="success" path="/helpdesk/GrievanceRedressalMechanism/ComplaintDetails.jsp"/>
                   <forward name="showmeetingform" path="/helpdesk/complaint/MeetingDetailsForm.jsp"/>
                   <forward name="transconfirm" path="/helpdesk/GrievanceRedressalMechanism/TransConfirm.jsp"/>
                   <forward name="ViewCompForm" path="/helpdesk/GrievanceRedressalMechanism/ViewCompForm.jsp"/>
              </action>
    and
    Actionclass:
    ========
    * Created on Nov 5, 2004
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package com.srit.hrnet.helpdesk.grievancemechanism;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.List;
    import java.util.StringTokenizer;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import org.apache.commons.beanutils.BeanUtils;
    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.ActionMessage;
    import org.apache.struts.action.ActionMessages;
    import org.apache.struts.action.DynaActionForm;
    import org.apache.struts.actions.DispatchAction;
    import org.apache.struts.upload.FormFile;
    import org.apache.struts.validator.DynaValidatorActionForm;
    import org.apache.struts.validator.DynaValidatorForm;
    import com.srit.hrnet.components.SequenceCodeGenerator;
    import com.srit.hrnet.emp.EmployeeGenTO;
    import com.srit.hrnet.emp.courier.CourierMailDAO;
    import com.srit.hrnet.emp.courier.CourierMailTO;
    import com.srit.hrnet.emp.parameter.ParamMasterTO;
    import com.srit.hrnet.helpdesk.SessionValidate;
    import com.srit.hrnet.helpdesk.category.CategoryDAO;
    import com.srit.hrnet.helpdesk.category.CategoryTO;
    import com.srit.hrnet.helpdesk.mails.HDMail;
    import com.srit.hrnet.utilities.DateUtilities;
    import com.srit.hrnet.helpdesk.complaint.TaskDAO;
    import com.srit.hrnet.helpdesk.SessionValidate;
    import com.srit.hrnet.helpdesk.grievancemechanism.GrievanceComplaintForm;
    public class GrievanceComplaintAction extends DispatchAction{
         public ActionForward submitForm(ActionMapping mapping,
                   ActionForm form, HttpServletRequest request,
                   HttpServletResponse response)throws ServletException,IOException {  
                   String msg=null;
                   DynaValidatorActionForm objDyna = (DynaValidatorActionForm)form;
                   GrievanceComplaintDAO gcDao= new GrievanceComplaintDAO();
              ActionForward forward = new ActionForward();
    //          GrievanceComplaintForm gcForm=(GrievanceComplaintForm)form;
                        String CompId = null;
              try
                             SequenceCodeGenerator seq=new SequenceCodeGenerator("GrievanceMechanism");
                             CompId=seq.generateCode();
                   GrievanceComplaintTO gcTO=new GrievanceComplaintTO();
                   System.out.println("Inside GrievanceComplaintAction ......");
                   String CompName=request.getParameter("complaintName");
                   String Category=request.getParameter("category");
                   String prority=request.getParameter("priority");
                   String dateofocc=request.getParameter("occdate");
                   String timeofocc=request.getParameter("occtime");
                   String desc=request.getParameter("desc");
                   String comments=request.getParameter("comments");
    //          String file=request.getParameter("file");
    //          String complaintcode = .generateCode();
                   System.out.println("Inside insert()::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
                   System.out.println("Name Of the Complaint name>>>>>>>>>>>>>>"+CompName);
                   System.out.println("Name Of the Categoryt>>>>>>>>>>>>>>"+Category);
                   System.out.println("Name Of the prority>>>>>>>>>>>>>>"+prority);
                   System.out.println("Name Of the dateofocc>>>>>>>>>>>>>>"+dateofocc);
                   System.out.println("Name Of the timeofocc>>>>>>>>>>>>>>"+timeofocc);
                   System.out.println("Name Of the desc>>>>>>>>>>>>>>"+desc);
                   System.out.println("Name Of the comments>>>>>>>>>>>>>>"+comments);
    //          System.out.println("Name Of the file>>>>>>>>>>>>>>"+file);
                   GregorianCalendar occdate=DateUtilities.getGCDateForString(objDyna.getString("occdate"),((com.srit.hrnet.emp.EmployeeGenTO)request.getSession().getAttribute("LoginUser")).getDateFormat(),'/');
                   gcTO.setComplaintCode(CompId);
                   gcTO.setComplaintName(CompName);
                   gcTO.setCategory(Category);
                   gcTO.setPriority(prority);
                   gcTO.setOccdate(occdate);
                   System.out.println("After Setting date in GTO is>>>>>>>>>>>>>>"+gcTO.getOccdate());
                   gcTO.setOcctime(timeofocc);
                   gcTO.setDesc(desc);
                   gcTO.setComments(comments);
                        HDMail mailComp = new HDMail();
                   String errorFlag = null;
                   String filePath = ""+objDyna.get("file");// Attachment path
                   StringTokenizer st=new StringTokenizer(filePath,".");
                   String extension=null;
    //               String filename=null;
                   String attachmentPath = null;
                   while(st.hasMoreTokens())
                        extension=st.nextToken();
    //          while(st1.hasMoreTokens()){
    //               filename=st1.nextToken();
                   System.out.println("Attachment path : "+attachmentPath);
              System.out.println("Extension is.........."+extension);
    //          System.out.println("Name of the file is.............."+filename);
              if(filePath != null && filePath.indexOf(".") != -1 && filePath.length()>=5 ){// If attachment exists
    //               attachmentPath = filePath.substring(filePath.indexOf(".")+1,filePath.length());// file extension
    ////               System.out.println("Attachment path : "+attachmentPath);
                   if(!extension.equalsIgnoreCase("txt") && !extension.equalsIgnoreCase("htm")
                             &&!extension.equalsIgnoreCase("doc") &&!extension.equalsIgnoreCase("rtf")
                                       &&!extension.equalsIgnoreCase("msg") &&!extension.equalsIgnoreCase("oft")
                                       && !extension.equalsIgnoreCase("xls")){
                        errorFlag = "1"; // if the file is not a valid type (not in the above mentioned extensions)
              gcTO.setAttachmentName(filePath);
              if(errorFlag.equals("1")){
    //          String attachmentName = null;
    ////          String attachmentPath = request.getParameter("agendaAttachment");
    //          DynaValidatorForm dyna=(DynaValidatorForm)form;
    //                         FormFile file= (FormFile)objDyna.get("file");
    //                         //dyna.get("file");      
    //          System.out.println("Name of the file after casting....."+file.getFileName());
    //                         if(file!=null && file.getFileName()!=null && !file.getFileName().trim().equals("")){
    //                              String fileName = null;                         
    //                              fileName = file.getFileName();
    //                              attachmentName = fileName;
    //                              if(validFile(fileName))
    //                              writeFile(file,request,fileName);
    //                              else
    //                                   ActionMessages errors=new ActionMessages();
    //                                   errors.add("Err:MsgDesc",new ActionMessage("com.srit.hrnet.helpdesk.complaint.form.fileupload"));                              
    //                                   saveErrors(request,errors);                         
    ////                                   ActionForward map1 = submitSubCategory(mapping,form,request,response);                              
    //                                   resetToken(request);     
    //                                   saveToken(request);
    //                                   return mapping.findForward("ViewCompForm");                              
    //                    int recordexists = gcDao.getComplaint(CompId);
    //                    if(recordexists == 1){
    //                         System.out.println("Calling the update method");
    //                         gcDao.updateComplaintDetails(gcTO);     
    //                    }else{
                        boolean retVal=gcDao.insert(gcTO);
              if (retVal){
                   System.out.println("Record Inserted inside Action.");
                   msg = "<font color='blue'>Record Inserted Successfully .</font>";
                             request.setAttribute("status", msg);
              else{
                   System.out.println("Unable to insert Record inside Action.");
                   msg = "<font color='red'>Unable to insert Record .</font>";
                             request.setAttribute("status", msg);
              else
                   System.out.println("Upload a file of extension(.jpg,.gif,.doc,.htm,.xls,.rtf,oft,msg) inside Action.");
                   msg = "<font color='red'>Upload a file of extension(.jpg,.gif,.doc,.htm,.xls,.rtf,.oft,.msg) </font>";
                             request.setAttribute("status", msg);
              catch (Exception e) {
                   // TODO: handle exception
                   System.out.println("Exception Occurred inside insert action....."+e.getMessage());
                   e.printStackTrace();
    //          else
    //               String insStatus="10";
    //               System.out.println("Accept:Redirecting due to resubmission");
    //               request.setAttribute("transStatus",insStatus);
    //               forward =mapping.findForward("transconfirm");
                   return mapping.findForward("success");
         public boolean validFile(String fileName){
              if(!fileName.equals("")){     
                        int filelength=fileName.length();
                        int sublength= fileName.indexOf('.');
                        String extension = fileName.substring(sublength+1,filelength);
                        if(extension.trim().equalsIgnoreCase("msg") || extension.trim().equalsIgnoreCase("txt") || extension.trim().equalsIgnoreCase("xls") || extension.trim().equalsIgnoreCase("ppt") || extension.trim().equalsIgnoreCase("jpg") || extension.trim().equalsIgnoreCase("gif")|| extension.trim().equalsIgnoreCase("doc" )|| extension.trim().equalsIgnoreCase("pdf") || extension.trim().equalsIgnoreCase("wmv") || extension.trim().equalsIgnoreCase("zip") || extension.trim().equalsIgnoreCase("jpeg") || extension.trim().equalsIgnoreCase("xml") || extension.trim().equalsIgnoreCase("html") ||extension.trim().equalsIgnoreCase("bmp") ||extension.trim().equalsIgnoreCase("htm") ||extension.trim().equalsIgnoreCase("ppt")||extension.trim().equalsIgnoreCase("oft")||extension.trim().equalsIgnoreCase("csv")){
                        return true;
                        }else{
                        return false;
                   return true;
         public int writeFile(FormFile file,HttpServletRequest request,String fileName){
                   int retValue = 0;
                   String size = (file.getFileSize() + " bytes");
                   if(file.getFileSize()>0){
                        //System.out.println("The size of the file is :" + file.getFileSize() + " bytes");
                        String data = null;
                        try {
                             //retrieve the file data
                             String fileTodelete = request.getRealPath("/helpdesk/meetingsagenda/"+fileName);
                             boolean success = (new File(fileTodelete)).delete();
                             //System.out.println("sucess......"+success);          
                             ByteArrayOutputStream baos = new ByteArrayOutputStream();
                             InputStream stream = file.getInputStream();
                             //write the file to the file specified
                             System.out.println("sfsdfkjdsfds "+request.getRealPath("/helpdesk/meetingsagenda/"+fileName));
                             OutputStream bos = new FileOutputStream(request.getRealPath("/helpdesk/meetingsagenda/"+fileName));
                             int bytesRead = 0;
                             byte[] buffer = new byte[8192];
                                  while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
                                       bos.write(buffer, 0, bytesRead);
                             bos.close();
                             data =      "The file has been written to \""+ "/helpdesk/meetingsagenda/"+ "\"";
                             System.out.println("data........."+data);
                                  //close the stream
                             stream.close();
                        }catch(FileNotFoundException fnfe) {
                                  System.out.println("com.srit.hrnet.homepage.fromceo.FromCEOAction.writeFile.Exception :"+ fnfe.toString());
                                  fnfe.printStackTrace();
                                  //retValue = FORMFILE_FILE_NA;
                        }catch(IOException ioe) {
                                  System.out.println("com.srit.hrnet.homepage.fromceo.FromCEOAction.writeFile.Exception :"+ ioe.toString());
                                  ioe.printStackTrace();
                                  //retValue = FORMFILE_ERR_UPD;
                   }//end of try catch:~
                   }else{
                        //The file was a not available
                        //retValue = FORMFILE_SIZE_ZERO;
                   }//end of if else:~
              //     System.out.println("retValue........."+retValue);
                   return retValue;                         
    }//end of ComplaintAction
    and GrievanceFormTO:(Dummy form bean)
    ==========
    * Created on Nov 4, 2004
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package com.srit.hrnet.helpdesk.grievancemechanism;
    import java.util.GregorianCalendar;
    import org.apache.struts.upload.FormFile;
    public class GrievanceComplaintTO implements java.io.Serializable {
    private String complaintCode;
    private String compcode; //complaind Id
    private String complaintName;
    private String category;
    private String priority;
    //private GregorianCalendar date;
    private FormFile theFile;
    private String compOption;
    private String desc;
    private String comments;
    private String status;
    private String serviceperson;     //employee who is going to serve the complaint.Applicatble only in case of manual flow.
    private String loggedEmpId; //the employee who has logged the complaint
    private String applyEmpId; //employee to whom the cmplaint belongs to or owner of the complaint
    private String associateComm;
    private String associateRating;
    private GregorianCalendar occdate;
    private String occtime;
    private String attachmentName;
         public String getApplyEmpId() {
              return applyEmpId;
         public void setApplyEmpId(String applyEmpId) {
              this.applyEmpId = applyEmpId;
         public String getAssociateComm() {
              return associateComm;
         public void setAssociateComm(String associateComm) {
              this.associateComm = associateComm;
         public String getAssociateRating() {
              return associateRating;
         public void setAssociateRating(String associateRating) {
              this.associateRating = associateRating;
         public String getCategory() {
              return category;
         public void setCategory(String category) {
              this.category = category;
         public String getComments() {
              return comments;
         public void setComments(String comments) {
              this.comments = comments;
         public String getCompcode() {
              return compcode;
         public void setCompcode(String compcode) {
              this.compcode = compcode;
         public String getComplaintName() {
              return complaintName;
         public void setComplaintName(String complaintName) {
              this.complaintName = complaintName;
         public String getCompOption() {
              return compOption;
         public void setCompOption(String compOption) {
              this.compOption = compOption;
         public String getDesc() {
              return desc;
         public void setDesc(String desc) {
              this.desc = desc;
         public String getLoggedEmpId() {
              return loggedEmpId;
         public void setLoggedEmpId(String loggedEmpId) {
              this.loggedEmpId = loggedEmpId;
         public String getOcctime() {
              return occtime;
         public void setOcctime(String occtime) {
              this.occtime = occtime;
         public String getPriority() {
              return priority;
         public void setPriority(String priority) {
              this.priority = priority;
         public String getServiceperson() {
              return serviceperson;
         public void setServiceperson(String serviceperson) {
              this.serviceperson = serviceperson;
         public String getStatus() {
              return status;
         public void setStatus(String status) {
              this.status = status;
         public String getComplaintCode() {
              return complaintCode;
         public void setComplaintCode(String complaintCode) {
              this.complaintCode = complaintCode;
         public void setOccdate(GregorianCalendar occdate) {
              this.occdate = occdate;
         public GregorianCalendar getOccdate() {
              return occdate;
         public String getAttachmentName() {
              return attachmentName;
         public void setAttachmentName(String attachmentName) {
              this.attachmentName = attachmentName;
         public FormFile getTheFile() {
              return theFile;
         public void setTheFile(FormFile theFile) {
              this.theFile = theFile;
    but i am getting error
    javax.servlet.ServletException: BeanUtils.populate
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:497)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:205)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.srit.hrnet.filter.SessionValidateFilter.doFilter(SessionValidateFilter.java:81)
    root cause
    org.apache.commons.beanutils.ConversionException: Cannot assign value of type 'org.apache.struts.upload.CommonsMultipartRequestHandler$CommonsFormFile' to property 'file' of type 'java.lang.String'
         org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:424)
         org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1733)
         org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
         org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
         org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
         org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
         org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:205)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.srit.hrnet.filter.SessionValidateFilter.doFilter(SessionValidateFilter.java:81)
    and my jsp is:
    =========
    <%@ page language="java" %>
    <%@ taglib uri="struts-bean" prefix="bean" %>
    <%@ taglib uri="struts-html" prefix="html" %>
    <%@ taglib uri="struts-logic" prefix="logic" %>
    <%@ taglib uri="TabGenerator" prefix="GenerateTab" %>
    <%@ page import="com.srit.hrnet.utilities.DateUtilities"%>
    <%@ page import="com.srit.hrnet.components.BasicDAOConstants" %>
    <%@ taglib uri="AccessLogin" prefix="GeneralAccess" %>
    <%@ taglib uri="iterateTag" prefix="iterateTag" %>
    <%@ page import="com.srit.hrnet.components.BasicDAOConstants,com.srit.hrnet.emp.EmployeeGenTO,com.srit.hrnet.helpdesk.grievancemechanism.*"%>
    <%@ page import="com.srit.hrnet.tags.*"%>
    <html:html locale="true">
    <HEAD>
         <TITLE>
                   <bean:message key="com.srit.hrnet.helpdesk.complaint.form.title"/>
         </TITLE>
         <META NAME="Generator" CONTENT="EditPlus">
         <META NAME="Author" CONTENT="">
         <META NAME="Keywords" CONTENT="">
         <META NAME="Description" CONTENT="">
    <link rel="stylesheet" type="text/css" href="<%= (session.getAttribute("LoginUser") != null ?
                             ((com.srit.hrnet.emp.EmployeeGenTO)session.getAttribute("LoginUser")).getEmpPageStyleSheet() :
                             com.srit.hrnet.components.access.AccessCodes.GLOBAL_STYLESHEET)%>">
    <script language="javaScript" src="<%= request.getContextPath()%>/jscript/GlobalValidationScript.js" purpose="include"></script>
    <%      
    int dateFormat = (session.getAttribute("LoginUser") != null ? ((com.srit.hrnet.emp.EmployeeGenTO)session.getAttribute("LoginUser")).getDateFormat() : 2);
         System.out.println("/reports/training/TRngBaseReport dateFormat = "+dateFormat);
         /* *** get the current date *** */
         java.util.GregorianCalendar gc1 = new java.util.GregorianCalendar();
         int yy = gc1.get(java.util.Calendar.YEAR);
         int mm = gc1.get(java.util.Calendar.MONTH);
         int dd = gc1.get(java.util.Calendar.DATE);     
         mm = mm + 1;
         String mon;
         String day;
         if(dd <= 9)
              day = "0" + java.lang.String.valueOf(dd);
         else
              day = java.lang.String.valueOf(dd);
         if(mm <= 9)
              mon = "0" + java.lang.String.valueOf(mm);
         else
              mon = java.lang.String.valueOf(mm);
         java.lang.String currentDate = "";
         if(dateFormat == 3){
              currentDate = java.lang.String.valueOf(yy+"/"+mon+"/"+day);/* (yyy-mm-dd format) */
         }else if(dateFormat == 1){
              currentDate = java.lang.String.valueOf(mon+"/"+day+"/"+yy);/* (mm-dd-yyy format) */
         }else if(dateFormat == 2){
              currentDate = java.lang.String.valueOf(day+"/"+mon+"/"+yy);/* (dd-mm-yyy format) */
         System.out.println("/reports/training/TRngBaseReport currentDate = "+currentDate);
    %>
    <script language="javaScript" src="<%= (session.getAttribute("LoginUser")!=null ? ((com.srit.hrnet.emp.EmployeeGenTO)session.getAttribute("LoginUser")).getScriptFile() : "")%>" purpose="include"></script>
    <script language="javaScript" src="jscript/CommonDialog.js" purpose="include"></script>
    <script language="javaScript" src="jscript/GlobalValidationScript.js"></script>
    <script language="javascript">
         var gNow = new Date("<%=currentDate%>");
         function val_complaint()
    if(document.GreivanceForm.complaintName.value.length==0)
         alert("Enter Complaint Name");
         document.GreivanceForm.complaintName.focus();
         return false;
    if(document.GreivanceForm.category.value =='NA')
         alert("select category");
         document.GreivanceForm.category.focus();
         return false;
    if(document.GreivanceForm.priority.value == 'NA')
         alert("select priority");
         document.GreivanceForm.priority.focus();
         return false;
         if(document.GreivanceForm.occdate.value == "")
              alert("Enter Date (dd/mm/yy)");
              document.GreivanceForm.occdate.focus();
              return false;
         else     
         if(document.GreivanceForm.occdate.value>document.GreivanceForm.currentDate.value){
                   alert("select Previous or Current date");
                   document.GreivanceForm.occdate.focus();
                   return false;
         if(document.GreivanceForm.occtime.value == "")
         alert("Select Time of Occurence.");
         document.GreivanceForm.occtime.focus();
         return false;
    else
    if(!IsValidTime(document.GreivanceForm.occtime.value) )
    alert("Enter Valid Time (HH:MM)");
              return false;
         if(document.GreivanceForm.desc.value == "")
         alert("Enter Description");
         document.GreivanceForm.desc.focus();
         return false;
              document.forms[0].compOption.value='submitForm';
              document.forms[0].submit();
              return false;
         function IsValidTime(givenTime)
              var hour = 0;
              var minute = 0;
              var timePat = /^(\d{1,2}):(\d{1,2})?$/;
              var matchArray = givenTime.match(timePat);
              if (matchArray == null)
                   alert("Enter Valid Time.");
                   return false;
              hour = matchArray[1];
              minute = matchArray[2];
              if(hour==0 && minute==0)
              alert("The Time You Entered is 0:0");
              return false;
              if (hour < 0 || hour > 23)
              alert("Hour must be between 0 and 23");
              return false;
              if (minute<0 || minute > 59)
              alert ("Minute must be between 0 and 59.");
              return false;
              return true;
    unction help(url)
         var attributes = 'menubar=no,toolbar=no,location=no,width=625,height=375,resizable=yes';
         var name = 'Help';
         window.open(url,name,attributes);
    //return false;
    </script>
    <script language = "javaScript" src = "<%=request.getContextPath()%>/jscript/CommonDialog.js" purpose = "include"></script>
    </HEAD>
    <body bgcolor="#FFFFFF" onload="setFocus()">
    <GenerateTab:displaytabs tabId="<%=com.srit.hrnet.masters.gui.GUIConstants.HD_GRIEVANCE_REDRESSAL_FORM%>" activeSubTab="0" >
    <table align="right">
              <tr>
                   <td>
                        <img src="<%=request.getContextPath()%>/images/help.gif" border="0" alt="Help">
                   </td>     
              </tr>     
         </table>
         <html:form action="/helpdesk/GrievanceComplaint" enctype="multipart/form-data" method="POST" onsubmit="javascript:return val_complaint()">
         <html:hidden property="compOption" value="submitForm" />
         <html:hidden property="onbehalf"/>
         <html:hidden property="employeeId"/>
         <html:hidden property="hidSelectedNames"/>
         <html:hidden property="selectedrequestor"/>
         <html:hidden property="individual"/>
         <table cellpadding="3" cellspacing="0" align="center" >
              <th align="center" class="tablehead" colspan="2">
              <b> Complaint Form </b>
              </th>
    <tr>
                   <td colspan="1" class='tablesubhead'>
                   <b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.complaintname"/></b><font class="star"> *</font>
                   </td>
                   <td class='subhead'>
                   <html:text property="complaintName" maxlength="99"/>
                   </td>
              </tr>
         <tr>
                   <td class='tablesubhead' colspan="1"><b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.category"/></b>
                   <font class="star">*</font></td>
                        <td class="tableright" property="category" >
                        <iterateTag:iterate propertyName='<%=IterateInterface.ITERATE_HELPDESK_GRIEVANCE_CATEGORY%>' defaultSelected='<%=request.getAttribute("category")==null?null:""+request.getAttribute("category")%>' selectSize='<%=100%>' tabInd='<%="3"%>'>
                        </iterateTag:iterate>
                   </td>
              </tr>
              <tr>
                   <td class='tablesubhead' colspan="1"><b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.priority"/></b>
                   <font class="star">*</font></td>
                   <td class="subhead">
                        <iterateTag:iterate propertyName='<%=IterateInterface.ITERATE_HELPDESK_GRIEVANCE_PRIORITY%>' defaultSelected='<%=request.getAttribute("priority")==null?null:""+request.getAttribute("priority")%>' selectSize='<%=100%>' tabInd='<%="3"%>'>
                                  </iterateTag:iterate>
                   </td>
         </tr>
         <tr>
                             <td class='tablesubhead' colspan=1><b>Date of Occurence</b>
                             <font class="star">*</font> </td>
                             <td class="subhead">     
                             <html:text name="GreivanceForm" property="occdate" maxlength="10"/>
                             <input type="hidden" name="currDate" />
                             <img src="<%= request.getContextPath()%>/images/calendar.jpg" border="0" alt="Calendar" >
                             </td>                         
                   </tr>
                                  <tr>
                                       <td class='tablesubhead' colspan=1><b>Time of Occurence</b>
                                       <font class="star">*</font></td>
                                       <td class="subhead">     
                                       <html:text name="GreivanceForm" property="occtime" maxlength="10"/> (24 Hrs format)</td>
                             </tr>
                             <tr>
                        <td class="tablesubhead" colspan=1>
                             <b>Description</b>
                             <font class="star">*</font></td>
                                       <td class="subhead">
                                       <html:textarea property="desc" styleClass="formObject" cols="40" rows="4"></html:textarea>
                                       </td>
                        </tr>
                   <tr>
              <td class="tablesubhead" colspan=1>
                   <b>Comments/Suggestions</b>
              </td>
                             <td class="subhead">
                             <html:textarea property="comments" styleClass="formObject" value="" cols="40" rows="4"></html:textarea>
                             </td>
                   </tr>
                   <tr>
                   <td class="tableleft">
              <b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.attachment"/> </b>
                                  </td>
                             <td class="tableright">
                                  <html:file property="file" size="18" />
                             </td>
              </tr>
                   <tr>
                   <td colspan="2" align="center" class="tablesubhead">
                   <input type="submit" class="submit" value="Submit" >
                    <html:reset property="reset" styleClass="submit" />
                   </td>
              </tr>
    </table>
         <input type="hidden" name="currentDate" value="<%=currentDate%>">
    </html:form>
    </GenerateTab:displaytabs>
    <html:javascript formName="/SubmitComplaint"/>
    </body>
    </html:html>
    please help me..

    VAS_MS wrote:
    please help me..First help yourself by posting a clear question
    You have far to much code posted and without the use of the correct code tags its almost unreadable.
    You have a question about uplaoding files with Struts then get rid of all the junk in your code thats not related to uploading files.
    If you have an error then post the relevant information on the error
    like
    org.apache.commons.beanutils.ConversionException:
    Cannot assign value of type 'org.apache.struts.upload.CommonsMultipartRequestHandler$CommonsFormFile' to property 'file' of type 'java.lang.String'
    org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:424)If you had posted only that you would have given enough information, that error says it all you are trying to put your file into a String and its not working.
    reread the tutorial/documentation provided and try again
    Edited by: pgeuens on 21-mrt-2008 8:04

  • Run Into Problem When Trying Not To Hard Code the Host Name

    My code (using the JavaMail API) works fine when the SMTP host name is hard coded in the program:
           props.put( "mail.smtp.host", "TheHostName" );Then, I tried to put the host name in a properties file (smtpServer.properties). The properties file is in the $TOMCATHOME\webapps\AppName\WEB-INF\classes\resources directory. And the properties file has this one single line:
    smtpServer = TheHostName     //Note: The host name has only alpha characters, dots, and dashesIn my program, I did:
       private final String PROPFILE = "resources/smtpServer.properties";
       private Properties oProp = null;
       public SendBatchMails()  // this is the constructor in my class
          try
             oProp = new Properties();
             oProp.load ( getClass().getClassLoader().getResourceAsStream( PROPFILE ) );
          catch( IOException oEx )
             System.out.println("Unable to load the Properties " + PROPFILE + oEx );
           String smtpServer = oProp.getProperty( "smtpServer" );
           Properties props = System.getProperties();
           props.put( "mail.smtp.host", smtpServer );And, I got this runtime error:
    java.lang.IllegalArgumentException: argument type mismatch
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:324)
         org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
         org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
         org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
         org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
         org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    I would agree with Reply 1. From the stack trace it is apparent that it comes from Struts, where it is failing to set some kind of property in a bean. However the code that you posted doesn't seem to have anything to do with that. Check your Struts configuration.

  • Not creating bean while submitting form...

    i am using struts for displaying and updating data in jsp. my form bean is as follows:
    public class AppraisalDataForm extends ActionForm {
         private String name;
         private String appraisalId;
         private String empId;
         private String appraisalFromDate;
         private ArrayList<AppraisalHeadDt> appraisalHeadDts;
         private ArrayList<AppraisalPerformanceDt> appraisalPerformanceDts; 
                    // getters and settersAppraisalHeadDt.java is as follows:
    public class AppraisalHeadDt  implements Serializable {
         private AppraisalHeadDtPK compId;
         private String accessMode;
         private String appraiserComments;
         private String appraiserId;
         private Integer appraiserRating;
                    // getter and settersAppraisalHeadDtPK.java is as follows:
    public class AppraisalHeadDtPK implements Serializable {
         private String appraisalId;
         private String empId;
         private String headType;
                       // getters and settersmy Jsp is as follows:
    <logic:iterate id="appraisalHeadDt" indexId="index" name="AppraisalDataForm" property="appraisalHeadDts" type="com.yash.services.appraisal.hbeans.AppraisalHeadDt">
                                                <nested:define id="compId" name="appraisalHeadDt" property="compId" type="com.yash.services.appraisal.hbeans.AppraisalHeadDtPK"/>
                                                 <html:hidden name="appraisalHeadDt" property="compId.appraisalId" indexed="true"/>
                                                 <html:hidden name="appraisalHeadDt" property="compId.empId" indexed="true"/>
                                                 <tr>
                                                      <td align="center">
                                                           <html:select name="appraisalHeadDt" property="compId.headType" indexed="true">
                                                                <nested:options collection="HeaderTypes" labelProperty="value" property="key"/>
                                                           </html:select>
                                                      </td>
                                                      <td align="center">
                                                           <html:select name="appraisalHeadDt" property="waitage" indexed="true" >
                                                                <nested:options collection="Ratings" labelProperty="value" property="key"/>
                                                           </html:select>
                                                      </td>
                                                      <td align="center">
                                                           <html:select name="appraisalHeadDt" property="difficultyLevel" indexed="true" >
                                                                <nested:options collection="Ratings" labelProperty="value" property="key"/>
                                                           </html:select>
                                                      </td>                                            .
                                                                        .i want to display it on jsp and user can modify that data which need to submit in action class.
    now i m able to display data properly but at time of submiting data it throws exception :
    javax.servlet.ServletException: BeanUtils.populate
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
    java.lang.IllegalArgumentException: No bean specified
         org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)
         org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:937)

    Indexed forms are always difficult. And you've got a double nested item there.
    Can you pinpoint a bit better exactly which of the fields here is creating a problem?
    My instinct would be the one with the doubly nested bean - referring to the compId.headType"
    If you remove that control, do the other bits work correctly?
    You might try switching on some logging for the BeanUtils to see exactly which property it is trying to set on which bean and see the logging can give you more insight into what is happening.
    I would also suggest starting with a simpler example that works, and then building back up to this one.
    Hope this helps,
    evnafets

  • Problem with FileUpload with Struts

    Hello,
    Here is my form I've created :
    <html:form action="/UploadFile.do" method="post" enctype="multipart/form-data">
    <html:file property="file" />
    </html:form>
    The form I submit conatins a "file" attribute of FileForm type.
    I did exatcly as mentionned in different tutorials to upload files with Struts.
    But I get the following exception and I can't figure out what's happening:
    javax.servlet.ServletException: BeanUtils.populate
    at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
    java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Please Help !
    I'm using Struts 1.1 by the way
    Thank your for your help
    Hugo

    What is in the form bean you're using? You need a field that holds a FormFile object:
    import org.apache.struts.upload.*;
         private FormFile file;
         public FormFile getFile() {
              return this.file;
         public void setFile(FormFile file) {
              this.file = file;
    ...

  • 500 Internal Server Error - Null Pointer Exception

    Hi,
    I am using a Struts application. I get the following error while clicking a button in a JSP page. The mapping has been provided in the struts config.xml file. What could be the possible cause?
    java.lang.NullPointerException
         at org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1458)
         at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1013)
         at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
         at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
         at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:220)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)

    I am using a Struts application. I get the following error while clicking a button in a JSP page. The mapping has been provided in the struts config.xml file. What could be the possible cause?
    java.lang.NullPointerException
    at org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1458)

  • Java.lang.IllegalArgumentException: Cannot invoke beans

    in 1 jsp page
    <logic:iterate id="msgg" name="messages">
    <tr>
    <td>${msgg.messageNumber}</td>
    <td>${msgg.from[0]}</td>
    ** <td><html:link action="msgbody?message=${msgg.message}">${msgg.subject}</html:link> </td>
    <td>${msgg.sentDate}</td>
    </tr>
    </logic:iterate>
    ${msgg.message} which will return javax.mail.Message object
    By clicking in the link(above shown as **) it will go to msgbody action and should set
    message property of bean with javax.mail.Message object
    for msg body action my bean is
    package beans;
    import javax.mail.Message;
    import org.apache.struts.action.ActionForm;
    public class MsgBn extends ActionForm {
    private Message message;
    public Message getMessage() {
    return message;
    public void setMessage(Message message) {
    this.message = message;
    i am getting following exception plz suggest me solutions
    java.lang.IllegalArgumentException: Cannot invoke beans.MsgBn.setMessage - argument type mismatch
    org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778)
    org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
    org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
    org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
    org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
    org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
    org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
    org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)

    Of course it's a String. It's being passed as a request parameter. Request parameters are always Strings.
    It looks like something needs to be held in the session maybe?

Maybe you are looking for