Posted on 2006-04-22
Last Modified: 2010-04-01
how to call jsp from servlet.

could you give me the exact syntax
Question by:stmani2005
    LVL 11

    Expert Comment

    here is a good explanation about redirects, forwards etc.

    use request dispatcher to call jsp from servlet

    RequestDispatcher dispatcher = request.getRequestDispatcher("/relative/path/to/jsp");
    dispatcher.forward(request, response);

    LVL 8

    Author Comment

    >> "/relative/path/to/jsp"


    suppose my view.jsp is under wepapps/jsp.

    how could i specify relative path for that
    LVL 11

    Accepted Solution

    if your servlet is defined at the root path like


    then u can do the following

    RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/view.jsp");
    dispatcher.forward(request, response);

    it means /jsp/view.jsp path is relative to your context path.
    LVL 8

    Author Comment

    suppose i have username and password variable in servlet.

    how could i pass that variables, and view in jsp textboxes

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    This is an issue that we can get adding / removing permissions in the vCSA 6.0. We can also have issues searching for users / groups in the AD (using your identify sources). This is how one of the ways to handle this issues and fix it.
    Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    732 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

    22 Experts available now in Live!

    Get 1:1 Help Now