Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    54
    Rep Power
    0

    Default Errors come when i set attribute in request in Action Form

    public class EmailFriendForm extends ActionForm {
    private Boolean not_include_price = false;
    private String your_message;
    private String your_email;
    private String your_name;
    private String frend_email;
    private String productPrice;
    private static String email_pattern = "[0-9a-z-._]*@[0-9a-z-._]*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?";

    public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
    ActionErrors errors = new ActionErrors();
    HttpServletRequest request=null;
    if(your_name==null || !your_name.matches("^[^><]{1,100}$"))
    errors.add(ActionErrors.GLOBAL_ERROR, new ActionMessage("errors.sendEmailToFriend.your_name" ));
    if(your_email==null || your_email.equals("") || !your_email.toLowerCase().matches("^"+email_patter n+"$"))
    errors.add(ActionErrors.GLOBAL_ERROR, new ActionMessage("errors.sendEmailToFriend.your_email "));
    if(frend_email==null || frend_email.equals("") || !frend_email.toLowerCase().matches("^((" + email_pattern + ")(,\\s*?)?)+?$"))
    errors.add(ActionErrors.GLOBAL_ERROR, new ActionMessage("errors.sendEmailToFriend.friend_ema il"));
    request.setAttribute("sendEmail","Your Email!");
    return errors;
    }


    In this code i have added request.setAttribute("sendEmail","Your Email!");
    than error comes:
    java.lang.NullPointerException
    at com.elasticpath.web.struts.action.form.EmailFriend Form.validate(EmailFriendForm.java:32)
    at org.apache.struts.action.RequestProcessor.processV alidate(RequestProcessor.java:919)
    at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:204)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1192)
    at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:430)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at com.elasticpath.commons.HibernateSessionFilter.doF ilter(HibernateSessionFilter.java:29)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at com.elasticpath.commons.EncodingFilter.doFilter(En codingFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at com.elasticpath.commons.MemoryStatusFilter.doFilte r(MemoryStatusFilter.java:35)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at com.elasticpath.commons.AntiCacheFilter.doFilter(A ntiCacheFilter.java:33)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter .doFilter(UrlRewriteFilter.java:738)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.CustomPrincipalValve .invoke(CustomPrincipalValve.java:39)
    at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:159)
    at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:59)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread .run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Unknown Source)
    16:55:18,781 ERROR [[action]] Servlet.service() for servlet action threw exception

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    You get a null pointer exception there. So did you debug the code? It's the simplest way to sort out the issue. :)

  3. #3
    Join Date
    Jun 2008
    Posts
    54
    Rep Power
    0

    Default

    Ok...my question is why this error come ...Can i set value in request in validate method....because i want tis value on jsp

  4. #4
    daGame is offline Member
    Join Date
    May 2008
    Posts
    24
    Rep Power
    0

    Default

    Quote Originally Posted by 82rathi.angara View Post
    request.setAttribute("sendEmail","Your Email!");
    In this code i have added request.setAttribute("sendEmail","Your Email!");
    than error comes:
    java.lang.NullPointerException
    Did you check out how the setAttribute() method looks like in the javaDocs?
    Check it out and you'll come to know your mistake ;)

    Edit: Here is the JavaDocs

    Kind Regards,

    daGame.
    Last edited by daGame; 09-22-2008 at 03:11 PM. Reason: added javaDoc

Similar Threads

  1. Invalid usebean class attribute - new to java
    By grinsalot in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-04-2008, 05:54 AM
  2. Generate XML request from web form
    By sabatier in forum XML
    Replies: 1
    Last Post: 08-09-2007, 08:53 PM
  3. how to add an attribute with sax?
    By cecily in forum New To Java
    Replies: 3
    Last Post: 07-19-2007, 05:09 AM
  4. Problem with Attribute in JSP
    By Albert in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-13-2007, 04:11 PM
  5. Request attribute PageBean = null
    By Nick15 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 05-17-2007, 04:23 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
  •