• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

Can't get to JSP using getRequestDispatcher

My Servlet goGet method is as follows:

public void doGet (HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException   {
        try {
                     RequestDispatcher rd = getServletContext().getRequestDispatcher("eei.jsp");
           rd.forward(req, res);

        } catch(Exception e) {

I am using Ant to build a war file that gets deployed.  Using
            <war destfile="in.war"

A few points
1) I deploy my jsp's in the top level (main) project folder in the war archive.
2) I tried it using the following line in my servlet and it failed also:
'RequestDispatcher rd = getServletContext().getRequestDispatcher("/eei.jsp");'

It works fine if I do all the following
1) Don't put my files in a war archive (copy them over directly - exploded) when I deploy.
2) Have a folder called "jsp" under my main project folder parallel to the WEB-INF folder and put my jsp's there.  
3) And use the line 'RequestDispatcher rd = getServletContext().getRequestDispatcher("/jsp/eei.jsp");' instead
of 'RequestDispatcher rd = getServletContext().getRequestDispatcher("eei.jsp");' in my servlet.

I need to make it work the first way though.
I am using Weblogic 9 application server.

Please help,


2 Solutions
> 'RequestDispatcher rd = getServletContext().getRequestDispatcher("/eei.jsp");'

I would have thought that should work.

Have you checked that eei.jsp is in the root directory of your war
Mayank SAssociate Director - Product EngineeringCommented:
>> getServletContext().getRequestDispatcher("/jsp/eei.jsp");

Does that work when it is in the WAR (maybe that the JSP is not in the root directory of the WAR).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now