This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception when calling jsp from servlet p/s help!  RSS feed

 
no_nos
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having this exception:
java.lang.NullPointerException
at org.apache.jsp.B1GenPage1$jsp._jspService(B1GenPage1$jsp.java:136)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853).... and the rest..
It happens each time I make a first call of a jsp from a servlet.. but after the first call everyruns fine.
i use requestDispatcher.forward(request,response) to forward request to a jsp.
P/s help, i am quite new to jsp
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need to post more code. Could it be possible that you are calling a method on a reference that's not initialized the first time it is accessed?
 
no_nos
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually this is the function responsible for calling the jsp page:
public JspForwarder(HttpServletRequest request, HttpServletResponse response,ServletContext context,
String nextPage)throws ServletException, IOException
{
RequestDispatcher rd = context.getRequestDispatcher(nextPage);
if(rd!=null)
{
rd.forward(request,response)
}
}
i initialise the ServletContext in the init function of which i pass over to jspForwarder(...) to call the jsp page
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!