This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes Is this illegal in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Is this illegal in JSP" Watch "Is this illegal in JSP" New topic
Author

Is this illegal in JSP

Sree Mami
Ranch Hand

Joined: Jul 13, 2006
Posts: 75
Hi all,

I have problem forwarding request to other JSP pages from my current jsp page. My code includes:

Form1:


Form2:


Form3:



Please clarify, as I am getting NullPointerException in the line forwarding page to Form1.jsp.
nizams uddin
Greenhorn

Joined: Jul 31, 2006
Posts: 15
check whether the hidden variable is between form tags
Sree Mami
Ranch Hand

Joined: Jul 13, 2006
Posts: 75
Ya that may be true, I just tried and got success.

Thanks for the valuable information..
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
best way to avoid any future NPE, check
if(fname != null && fname.equals("FORM1")){ .... }


SCJP5
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
Another way to do it is to write the logic like this:



It will never result in a null pointer exception, and has the same effect at the end of the day.
 
jQuery in Action, 2nd edition
 
subject: Is this illegal in JSP