• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Forwarding users from one JSP to another using a form.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

  •  
    Bartender
    Posts: 1845
    10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Popeye has his spinach. I have this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic