• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forwarding users from one JSP to another using a form.

 
Awet Haddis
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Background:

I have an 'upload' page in my webapp that allows the user to upload data of her own. Once the user presses the 'submit' button,
I want her to be forwarded to the 'summary' page where I return the result of validation (success or failure). Once the user makes
the request, my servlet will handle it.

Problem/Error:

When I hit the 'submit' button, I encounter this error:




My JSP (summaryReport.jsp)



Any help would be greatly appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Three things:

  • Terminology matters. A form submission is not a forward. A forward is a very specific thing that occurs on the server and has nothing to do with form submission.
  • Submitting to a JSP for processing is a very old-fashioned, outdated and discredited practice. The problem you are having is a good example why. Submit to a servlet for processing, and then forward (a real forward this time) to a JSP for the view. Under such a scenario, it's practically impossible to get a NPE in a JSP. If there's a problem, it will be found in the servlet where it's much easier to diagnose and deal with.
  • Java scriptlets and scriptlet experssions in a JSP are also discredited and out-dated. Update your JSP knowledge to encompass the JSTL and EL.

  •  
    Stefan Evans
    Bartender
    Posts: 1784
    10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Its a null pointer exception.

    So you have to ask yourself what on this page is going to be null?
    After a quick inspection of the code, the only variable you are really referencing is "props"



    I would hypothesize that the request attribute "props" has not been initialized. Where is it supposed to come from?
    It looks like you are using it as a source of message resources - the text to print out on the page. Probably to do with translation/i18n.
    The preferred JSP approach would be to use a custom tag for that. eg the JSTL <fmt:message> tag.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic