By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

The server encountered an internal error () that prevented it from fulfilling this re

sid0404
P: 16
Hi

I am working with the Tomcat 5.5 on Eclipse, and is getting the error when my servlet calls the jsp using request dispatcher, the error is:

HTTP status 500

The server encountered an internal error () that prevented it from fulfilling this request.

and the log of the exception is:

Oct 27, 2008 9:41:15 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Controller threw exception
java.lang.NullPointerException
at Controller.doGet(Controller.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:627)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:729)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)

and when I go to the line in the controller.java which is giving me the exception, I do not find anything wrong with it, this is the line:

RequestDispatcher dispatcher = getServletConfig().getServletContext().getRequestD ispatcher("/view.jsp");
dispatcher.forward(request, response);

Any clarifications highly appreciated.

When I debug my code, I find that the config is null just before the RequestDispatcher line. What does that mean ?

thanks.
Oct 27 '08 #1
Share this Question
Share on Google+
3 Replies


Expert 10K+
P: 11,448
You either didn't store your .jsp at the correct location or you have overridden the
init(ServletConfig config) method without calling the super.init(config) method.

kind regards,

Jos
Oct 27 '08 #2

sid0404
P: 16
My code looks like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4. import java.io.IOException;
  5. import java.util.*;
  6. import javax.servlet.*;
  7. import javax.servlet.http.HttpServlet;
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.servlet.http.HttpServletResponse;
  10. import javax.servlet.http.HttpSession;
  11.  
  12. /**
  13.  * Servlet implementation class Controller
  14.  */
  15. public class Controller extends HttpServlet {
  16.  
  17.     private static ArrayList<String> list_operations = new ArrayList<String>();
  18.     private static final long serialVersionUID = 1L;
  19.  
  20.     /**
  21.      * @see HttpServlet#HttpServlet()
  22.      */
  23.     public Controller() {
  24.         super();
  25.         // TODO Auto-generated constructor stub
  26.     }
  27.  
  28.     /**
  29.      * @see Servlet#init(ServletConfig)
  30.      */
  31.     public void init(ServletConfig config) throws ServletException {
  32.         // TODO Auto-generated method stub
  33.     }
  34.  
  35.     /**
  36.      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  37.      */
  38.     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  39.         // TODO Auto-generated method stub
  40.  
  41.  
  42.         String val = request.getParameter("value1");
  43.         System.out.println(val);
  44.  
  45.         HttpSession session = request.getSession(true);
  46.         System.out.println(session.getId());
  47.         RequestDispatcher dispatcher = getServletConfig().getServletContext().getRequestDispatcher("/view.jsp");
  48.         dispatcher.forward(request, response);
  49.     }
  50.  
  51.     /**
  52.      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  53.      */
  54.     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  55.         // TODO Auto-generated method stub
  56.  
  57.  
  58.         this.doGet(request, response);
  59.  
  60.     }
  61.  
  62. }
  63.  
  64.  
  65.  
I dont think i did anything like that !! Any idea what is going wrong with the code !!

Reply awaited.
Oct 27 '08 #3

Expert 10K+
P: 11,448
I dont think i did anything like that !!
Yes you did; you committed sin #2 (see my previous reply).

kind regards,

Jos
Oct 27 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.