aspose file tools*
The moose likes JSP and the fly likes Forwarding users from one JSP to another using a form. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Forwarding users from one JSP to another using a form." Watch "Forwarding users from one JSP to another using a form." New topic
Author

Forwarding users from one JSP to another using a form.

Awet Haddis
Greenhorn

Joined: Jan 25, 2011
Posts: 11
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

Joined: Jan 10, 2002
Posts: 61648
    
  67

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.


  • [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Stefan Evans
    Bartender

    Joined: Jul 06, 2005
    Posts: 1018
    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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Forwarding users from one JSP to another using a form.