Results 1 to 4 of 4
  1. #1
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Question getting messages from MessageResources file

    Hi All,
    I have created a small struts application.That application is working well accept error messages from Message Resources file are not appearing in my jsp page.Here are details about my application

    My resource file is in
    .../WEB-INF/src/resources/LoginResource.properties
    and in
    .../WEB-INF/classes/resources/LoginResource.properties

    My struts-config.xml entry is
    Java Code:
    <message-resources parameter="resources.LoginResource" null="false" />
    Validate method in ActionForm is
    Java Code:
    public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
    		   System.out.println("Now I am validating inputs");
    	    ActionErrors errors=new ActionErrors();
    	    if(username==null || username.equals("")) {
    	        System.out.println("@@@@@username not provided@@@@@");
    	         errors.add("username", new ActionMessage("error.username.required"));
    	    }
    	    if(password1==null || password1.equals("")) {
    	        System.out.println("@@@@@password not provided@@@@@");
    	         errors.add("password1", new ActionMessage("error.password1.required"));
    	    }
    	    if(password2==null || password2.equals("")) {
    	        System.out.println("@@@@@password not provided@@@@@");
    	         errors.add("password2", new ActionMessage("error.password2.required"));
    	    }
    	    return errors;
    	    }
    JSP code through which i am trying to print error messges is
    Java Code:
    <font size="4" color="red" face="times new roman">
          <html:errors/>
    </font>
    And my message resources file is
    Java Code:
    error.username.required="Please enter your UserName."
    error.password1.required="Please enter your Password."
    error.password2.required="Please re-enter your Password."
    When i am trying to run this application,messages are not displaying and i am not getting any errors.

    For testing i inserted in println statements in validate method.Those print statements are also not displaying in console.So i think control is not able to reach validate method.
    Do i need to add anything to Web.xml file ?
    I have tried a lot of solutions from online.no is one working.
    Can any body please tell me solution to this problem.
    Thanks in advance.
    Sireesha.

  2. #2
    Md Saim is offline Member
    Join Date
    Sep 2008
    Location
    Kolkata, India
    Posts
    20
    Rep Power
    0

    Default

    Firstly you check your Struts version....

    Use ActionError in Struts 1.1 or 1.0 Applications. Use ActionMessage in Struts 1.2 or above applications.

  3. #3
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Default

    Thanks for the reply,
    My struts version is 1.2. Before replacing with ActionMessage in my code i tried to run previous code once but now i got an exception.I didn't change any thing.But i got below exception..i can't understand what happened.

    Java Code:
    HTTP Status 500 - 
    
    --------------------------------------------------------------------------------
    
    type Exception report
    
    message 
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception 
    
    org.apache.jasper.JasperException: Exception creating bean of class user.UserForm: {1}
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    
    root cause 
    
    javax.servlet.ServletException: Exception creating bean of class user.UserForm: {1}
    	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
    	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
    	org.apache.jsp.pages.register_jsp._jspService(register_jsp.java:81)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    
    root cause 
    
    javax.servlet.jsp.JspException: Exception creating bean of class user.UserForm: {1}
    	org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:463)
    	org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:433)
    	org.apache.jsp.pages.register_jsp._jspx_meth_html_005fform_005f0(register_jsp.java:131)
    	org.apache.jsp.pages.register_jsp._jspx_meth_html_005fhtml_005f0(register_jsp.java:105)
    	org.apache.jsp.pages.register_jsp._jspService(register_jsp.java:72)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.
    
    
    --------------------------------------------------------------------------------
    
    Apache Tomcat/5.5.26
    I am really confused..i didn't change any code but i am getting this exception this time.
    Can any one please tell me what happened.
    Thanks in advance.
    Sireesha.

  4. #4
    Md Saim is offline Member
    Join Date
    Sep 2008
    Location
    Kolkata, India
    Posts
    20
    Rep Power
    0

    Default

    This type of exception is thrown when all the input fields in jsp are not available in action form variables.

    So Check ..........
    Are all the input fields in jsp in action form variables?

Similar Threads

  1. How to extend Messages Component
    By Jothi in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 05-20-2008, 09:50 AM
  2. Error Messages Not Showing Up
    By nvidia in forum Web Frameworks
    Replies: 0
    Last Post: 04-07-2008, 11:41 PM
  3. how can server send messages every 5 min?
    By dim_ath in forum Networking
    Replies: 7
    Last Post: 01-10-2008, 04:59 PM
  4. Log messages are not appearing in my log file
    By indu_raj in forum Java Servlet
    Replies: 1
    Last Post: 08-09-2007, 12:59 AM
  5. Jsf Error Messages - Retain
    By vaswin in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 08-05-2007, 09:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •