• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • 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"
                     basedir="."
                     excludes="**/*.java,**.*/*.war"
                     webxml="./WEB-INF/web.xml"/>

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,
Dave  

 
             
          

0
gdkinney_2
Asked:
gdkinney_2
2 Solutions
 
objectsCommented:
> '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
0
 
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).
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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