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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sid0404
    New Member
    • Jul 2008
    • 16

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

    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.cata lina.core.Stand ardWrapperValve invoke
    SEVERE: Servlet.service () for servlet Controller threw exception
    java.lang.NullP ointerException
    at Controller.doGe t(Controller.ja va:46)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:627)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:729)
    at org.apache.cata lina.core.Appli cationFilterCha in.internalDoFi lter(Applicatio nFilterChain.ja va:269)
    at org.apache.cata lina.core.Appli cationFilterCha in.doFilter(App licationFilterC hain.java:188)
    at org.apache.cata lina.core.Stand ardWrapperValve .invoke(Standar dWrapperValve.j ava:213)
    at org.apache.cata lina.core.Stand ardContextValve .invoke(Standar dContextValve.j ava:172)
    at org.apache.cata lina.core.Stand ardHostValve.in voke(StandardHo stValve.java:12 7)
    at org.apache.cata lina.valves.Err orReportValve.i nvoke(ErrorRepo rtValve.java:11 7)
    at org.apache.cata lina.core.Stand ardEngineValve. invoke(Standard EngineValve.jav a:108)
    at org.apache.cata lina.connector. CoyoteAdapter.s ervice(CoyoteAd apter.java:174)
    at org.apache.coyo te.http11.Http1 1Processor.proc ess(Http11Proce ssor.java:875)
    at org.apache.coyo te.http11.Http1 1BaseProtocol$H ttp11Connection Handler.process Connection(Http 11BaseProtocol. java:665)
    at org.apache.tomc at.util.net.Poo lTcpEndpoint.pr ocessSocket(Poo lTcpEndpoint.ja va:528)
    at org.apache.tomc at.util.net.Lea derFollowerWork erThread.runIt( LeaderFollowerW orkerThread.jav a:81)
    at org.apache.tomc at.util.threads .ThreadPool$Con trolRunnable.ru n(ThreadPool.ja va:689)
    at java.lang.Threa d.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:

    RequestDispatch er dispatcher = getServletConfi g().getServletC ontext().getReq uestDispatcher( "/view.jsp");
    dispatcher.forw ard(request, response);

    Any clarifications highly appreciated.

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

    thanks.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    You either didn't store your .jsp at the correct location or you have overridden the
    init(ServletCon fig config) method without calling the super.init(conf ig) method.

    kind regards,

    Jos

    Comment

    • sid0404
      New Member
      • Jul 2008
      • 16

      #3
      My code looks like this:

      Code:
      
      
      import java.io.IOException;
      import java.util.*;
      import javax.servlet.*;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      import javax.servlet.http.HttpSession;
      
      /**
       * Servlet implementation class Controller
       */
      public class Controller extends HttpServlet {
      	
      	private static ArrayList<String> list_operations = new ArrayList<String>();
      	private static final long serialVersionUID = 1L;
             
          /**
           * @see HttpServlet#HttpServlet()
           */
          public Controller() {
              super();
              // TODO Auto-generated constructor stub
          }
      
      	/**
      	 * @see Servlet#init(ServletConfig)
      	 */
      	public void init(ServletConfig config) throws ServletException {
      		// TODO Auto-generated method stub
      	}
      
      	/**
      	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
      	 */
      	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      		// TODO Auto-generated method stub
      		
      
      		String val = request.getParameter("value1");
      		System.out.println(val);
      		
      		HttpSession session = request.getSession(true);
      		System.out.println(session.getId());
      		RequestDispatcher dispatcher = getServletConfig().getServletContext().getRequestDispatcher("/view.jsp");
      		dispatcher.forward(request, response);
      	}
      
      	/**
      	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
      	 */
      	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      		// TODO Auto-generated method stub
      
      
      		this.doGet(request, response);
      		
      	}
      
      }
      I dont think i did anything like that !! Any idea what is going wrong with the code !!

      Reply awaited.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by sid0404
        I dont think i did anything like that !!
        Yes you did; you committed sin #2 (see my previous reply).

        kind regards,

        Jos

        Comment

        Working...