Can't get to JSP using getRequestDispatcher

Posted on 2006-04-10
Last Modified: 2008-03-04
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,


Question by:gdkinney_2
    LVL 92

    Accepted Solution

    > '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
    LVL 30

    Assisted Solution

    >> 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).

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    What is the compatible hibernate version for spring 4.3.1 10 50
    scoreUp challenge 14 40
    IT Company 5 55
    computer science syllabus 3 40
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now