Request dispatcher null

          The forward code we have is like
          public void forward(String url, HttpServletRequest request,
          HttpServletResponse response)
          throws ServletException, IOException
          RequestDispatcher dispatcher = getServletConfig().getServletContext().getRequestDispatcher(url);
          dispatcher.forward(request, response);
          My question is:
          As per the documents
          The pathname must begin with a "/" and is interpreted as relative to the current
          context root.
          if my URL is "http://www.abcz.com/<somepage>
          request dispatcher is null? and on one server (say A) that is a problem but other
          server(say B) when given the full URL behaves ok.
          on server A I am getting a null pointer exception , which on tracing happens to
          be the request dispatcher is null.(If http://www.abcz.com/<somepage> is URL) but
          no null pointer exception if url is "/<somepage>"
          On B its behaving fine when given the "http://www.abcz.com/<somepage> " as URL
          to the method.
          Both server A and B are running wl6. Is the difference in service pack cause of
          the problem?
          Internally does wl6 parses the URL to find a relative URL?
          Any help will be greatly appreciated.
          Thanks
          Rumpa
          

And the reason for that is, RequestDispatcher is per application
          scope. And RequestDispatcher comes from the ServletContext which is
          the current application scope. So it has to be relative url. If you
          need to forward to an absolute url, you can use sendRedirect instead.
          Bhaskar
          "Matt Krevs" <[email protected]> wrote in message news:<[email protected]>...
          > as far as i know, you should always specify relative urls when using request
          > dispatchers
          >
          > eg
          >
          > if the entire url is
          > http://myserver/theurl
          > you would code as follows
          >
          > RequestDispatcher dispatcher =
          > getServletConfig().getServletContext().getRequestDispatcher("/theurl");
          > dispatcher.forward(request, response);
          >
          > You definitely should not use complete URLs when calling
          > getRequestDispatcher()
          >
          > what happens on the server that returns a null dispatcher if you manually
          > type the address into the browser? Does weblogic find the resource? If not
          > then you have something specified differently in your server that doesn
          > work.
          >
          >
          > "RUMPA GIRI" <[email protected]> wrote in message
          > news:[email protected]...
          > >
          > > The forward code we have is like
          > > /**********************************************/
          > >
          > > public void forward(String url, HttpServletRequest request,
          > > HttpServletResponse response)
          > > throws ServletException, IOException
          > > {
          > > RequestDispatcher dispatcher =
          > getServletConfig().getServletContext().getRequestDispatcher(url);
          > > dispatcher.forward(request, response);
          > > }
          > > /***********************************************/
          > >
          > > My question is:
          > > As per the documents
          > > The pathname must begin with a "/" and is interpreted as relative to the
          > current
          > > context root.
          > > if my URL is "http://www.abcz.com/<somepage>
          > > request dispatcher is null? and on one server (say A) that is a problem
          > but other
          > > server(say B) when given the full URL behaves ok.
          > > on server A I am getting a null pointer exception , which on tracing
          > happens to
          > > be the request dispatcher is null.(If http://www.abcz.com/<somepage> is
          > URL) but
          > > no null pointer exception if url is "/<somepage>"
          > > On B its behaving fine when given the "http://www.abcz.com/<somepage> " as
          > URL
          > > to the method.
          > > Both server A and B are running wl6. Is the difference in service pack
          > cause of
          > > the problem?
          > >
          > > Internally does wl6 parses the URL to find a relative URL?
          > >
          > > Any help will be greatly appreciated.
          > > Thanks
          > > Rumpa
          > >
          > >
          

Similar Messages

  • Nested request dispatches when using RequestDispatcher in a Button action

    Hi all,
    I am new to JSF so I am probably missing something very simple, please help:
    The test case is simple: I created one visual web page with one button and one normal JSP file(named test.jsp) using Netbeans 5.5 with visual web pack on Sun Application Server 9 PE. The code action for the button is as follows:
    public String button1_action() throws Exception
            ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
            HttpServletRequest request = (HttpServletRequest) context.getRequest();
            HttpServletResponse response = (HttpServletResponse) context.getResponse();
            RequestDispatcher dispatcher = request.getRequestDispatcher("test.jsp");
            dispatcher.forward(request,response);
            return null;
        }Once the JSF page is loaded and the button is clicked, this exception occurs:
    ApplicationDispatcher[WebApplication1] Servlet.service() for servlet Faces Servlet threw exception
    javax.servlet.ServletException: WEB2651: Exceeded maximum depth for nested request dispatches: 20
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:837)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:697)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:532)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:465)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:353)
    at webapplication1.Page1.button1_action(Page1.java:242)
    Can anyone provide any advice on how to resolve this issue?

    Hi Rachel,
    As per the Servlet2.3 Javadoc:
    The pathname must begin with a "/" and is interpreted as relative to the current context root.
    If you make that change and include the complete path, then it would work fine.
    Ex:
    If your context looks like http://my.company.com/webapp1/ and if you were to have your forwardPortlet.jsp in a directory like:
    webapp1
      |
      |-> htdocs
             |
             |-> forwardPortlet.jsp
    then, your code would look like;
    RequestDiscpatcher d = request.getRequestDispatcher("/htdocs/forwardPortlet.jsp");
    HTH,
    thanks,
    harsha

  • Request dispatch problem

    To all
    The problem is that my request dispatching is not forwarding the request and I haven't got a clue why. I have a upload servlet which is working fine as it parses the request and the forwards you to the same jsp page or the next jsp page according to what values it extracts. However I have set up a bean to display the contentType() of each request which is sent to it from the jsp pages, however nothing is displayed when the request is forwarded from the upload servlet. this is what is happening .....
    public class upload extends HttpServlet {
    public void doPost( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException {
    HttpServletRequest request = _req;
    HttpServletResponse response = _res;
    parseMultiForm pMF = new parseMultiForm( _req );
    Hashtable values = new Hashtable();
    String param;
    while ( ( param = pMF.getNextParameter()) != null) {
    String value = pMF.getParameter();
    values.put(param, value);
    if (values.containsKey("submit")) {
    String url = (String) values.get("reload");
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + url);
    dispatcher.forward(request, response);
    if (values.containsKey("continue")) {
    String url = (String) values.get("next");
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + url);
    dispatcher.forward(request, response);
    The above servlet forwards the request to a jsp which does the following....
    <jsp:useBean id="info" scope="session" class="InfoBean" />
    <jsp:setProperty name="info" property="request" value="<%= request %>" />
    However infoBean does not receive anything when the request is forwarded from the servlet??
    Can anyone see anything obviously wrong?? is it to do with the JSP asking for the <%= request> and not receiving it because the request dispatcher has altered it in some way?
    Thanks in advance anyone
    Andy.

    I have exactly the same problem. I can�t make the servlet pass the request object to the target jsp.
    Try not changing the request nor the response. Unfortunatelly due to the kind of job i do inside my servlet there's no way i can't touch the request. So if you can make it work with mi advice please let me know.

  • Query Strings in Request Dispatcher Paths (PLT.16.1.1)

    I'm having trouble using query strings in a request dispatcher include to a servlet.
    I'm spitting debug out, and it looks like I'm calling:
    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/myServlet?myparam=myparamValue");
    And myparam isn't being set for myServlet.
    The same URL ("http://myhost:myport/myPortal/myServlet?mayparam=mayparamValue)
    runs fine standalone....

    I'm not sure of the exact dates (either this month or the next). But
    JSR168 will be supported in the service pack.
    Subbu
    T-Bone said the following on 11/18/2003 09:23 AM:
    Subbu Allamaraju <[email protected]> wrote:
    There is a known bug in WLS's servlet container that results in this
    behavior. Please contact support if you need an expedited solution.Thanks, they said to wait for SP2 sometime end of November.
    Can you tell me when it will be available?
    Also, when will JSR-168 v1.0 be supported?
    Subbu
    T-Bone said the following on 10/26/2003 03:14 PM:
    I'm having trouble using query strings in a request dispatcher includeto a servlet.
    I'm spitting debug out, and it looks like I'm calling:
    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/myServlet?myparam=myparamValue");
    And myparam isn't being set for myServlet.
    The same URL ("http://myhost:myport/myPortal/myServlet?mayparam=mayparamValue)
    runs fine standalone....

  • Exception occurred during event dispatching: Null pointer exception

    All,
    i have an applet which opens an applet window. in this applet window i have a list box.
    When a value in the list box is selected, i need to access a method in the applet(held in another class) that launches another window
    however i get the following error:
    Exception occurred during event dispatching: Null pointer exception
    (hope thats clear enough)
    p.s. i have created an instance of the class.

    That is not clear at all, but the cause for the exception is very easy:
    something is null that should not be null :)

  • Sender RFC adapter Error- request was null while trying to extract it.

    Hi All,
    I  have a scenario running in Production(PI 7.0 system) where SAP ECC sends RFC request through sender RFC adapter. The scenario was working fine but now I am getting the below error in default trace and I couldn't see any error in communication channel monitoring.
    java.lang.Exception: RfcServer[BAS_ECC_RFC_Snd]1[AFSenderD] request was <null> while trying to extract it.
    I have gone through the below thread and performed a full cache refresh but it didn't help :  
    [NULL]
    I have gone through SAP note:730870 and I couldn't get any help on this error. Can you please suggest your ideas to solve this issue.
    Thanks & Regards,
    Laawanya

    Hi Lawanya,
    Check you RFC and input data , whether the RFC call is able to get the data from ECC or not.
    you can test the same RFC in ECC with input data and you can check whether the RFC in ECC is return the value or not.
    I gues in your case the RFC in ECC is not return any data  to PI.

  • Urgent, creating xml files dynamically, request dispatcher problem

    hi all,
    Problem 1:
    There is a problem we are facing, while request dispatching.
    The files CBECBC.XML & CBECBC_Envelop.XML,
    both xml files. These files are created on request from the user, dynamically, and displayed on the browser,
    by including them in a jsp page.
    Here we face a problem when they are to be included into the jsp page.
    The error is the following :
    //////// Error ////////
    Could not find request dispatcher for the url CBECBC.xml
    Could not find request dispatcher for the url CBECBC_Envelop.xml
    The created files are stored in the "d:\pstudio35\desks\bank\BankWeb\".
    We are using " <jsp:include page="...."/> " (dynamic jsp include tag), to include the xml files.
    Problem 2:
    And could you just let me know how to include a xml file in a jsp file,
    so that the xml file is displayed in the exact format of xml(with the tags).
    I am using Pramati Studio 3.5
    Its urgent!!!
    Regards,
    Deepa Datar

    problem 2:
    either translate all < en > into < and > or display the XML in a textarea

  • Error: 'document.wwv_flow.request' is null or not an object.

    I've problems with the buttons in my Application.
    When I create one and click I after, I've allways the Error Message: Error: 'document.wwv_flow.request' is null or not an object.
    But if I create the same butten on my test application, I don't have this error message.
    Whats wrong?
    Thanks
    Dean

    Dean,
    Can you be a bit more specific? What it the difference between "my Application" and "my test application"? What are you doing differently when you are creating these buttons?

  • Unable to use Request Dispatcher; Duke $ Post;

    I am using a Controller Servlet to transfer control to a JSP using Request Dispatcher within doPost()
    RequestDispatcher rd;
    rd=req.getRequestDispatcher(URL);
    rd.forward(req,resp);
    I am seting a request object
    req.setAttribute("XXX",obj.func());
    prior to the Redirect;
    The page gets redirected to a JSP. I am unable to access req object in there.
    if i use
    String XXX = req.getAttribute("XXX");
    i get an error in the jsp as
    "req cannot be resolved"
    Do i need to import some directives? Please Reply

    The page gets redirected to a JSP. I am unable to
    access req object in there.
    if i use
    String XXX = req.getAttribute("XXX");
    i get an error in the jsp as
    "req cannot be resolved"
    Do i need to import some directives? Please ReplyThat's simple. Your req (which is the HttpServletRequest object) in the servlet becomes request in the JSP. That's always there. The compiler would not recognize req
    Use request.getAttribute("XXX"); in JSP
    Regards
    ***Annie***

  • Request dispatcher between 2 servers

    dear sear:
    can i use request dispatcher to go from one servers to another whith the same session.
    thanks,
    hamdi.

    Nope, Request dispatcher works with in its servlet container.
    May be you can you Request.sendRedirect()..
    not sure.

  • Passing Attribute in Request Dispatcher

    Hi,
    I am using servlet#1 to pass the value of an Attribute to servlet#2
    servlet #1 code
    ServletContext sc = getServletContext();
    request.setAttribute("name",value);
    RequestDispatcher rd = sc.getRequestDispatcher(url);
    rd.forward(request, response);
    servlet #2 code
    ServletContext sc = getServletContext();
    String string = (String) sc.getAttribute("name");
    when I run servlet #1 request dispatcher forwards request and response to servlet #2 but the Attribute value is not passed along
    what am I missing ?
    thanks VERY much for your response in advance and past responses !!
    Rick

    Hi rickdd,
    In servlet #2 you should get the value from
    servlet's Request object rather than ServletContext,
    because parameter is set with Request Object not with
    ServletContext.
    So modifiy the code as given below...
         /* Parameter is passed with servlet's Request Object.
          * So Next line needs to be commented.
         //ServletContext sc = getServletContext();
         //Here get the value from servlet's Request Object
         String string = request.getAttribute("name");
       This will work.
    Regards
    Goodieguy

  • NullpointerException request being null

    Hi,
    Iam using this method to invalidate a client cookie:
        protected static void invalidateCookie(HttpServletRequest request, HttpServletResponse response) {
            if (request == null) {
                return;
            for (Cookie c : request.getCookies()) {
                if (c != null && "xyz_usr".equals(c.getName())) {
                    c.setValue(UserFactory.CRYPT.encrypt("loggedout"));
                    c.setMaxAge(-1);
                    if (response != null) {
                        response.addCookie(c);
                    break;
        }Already added some null checking that might be unneeded. However, sometimes Iam getting a NullpointerException in this line:
    for (Cookie c : request.getCookies()) {but how can request be null here? The method invalidateCookie(.) is called from a non static method, so it cant be a multithreading issue.

A: NullpointerException request being null

Hi,
the reason why you get the NullPointerException is that request.getCookies() return null.
The java 1.5 compiler translates the enhanced for into the classical one:
for(Cookie c : request.getCookies()) will be translated into
Cookie[] $a = request.getCookies();
for(int $i = 0; $i < $a.length /* NullPointerException here */; $i++){
  Cookie c = $a[$i];
}best regards,
mus

Hi,
the reason why you get the NullPointerException is that request.getCookies() return null.
The java 1.5 compiler translates the enhanced for into the classical one:
for(Cookie c : request.getCookies()) will be translated into
Cookie[] $a = request.getCookies();
for(int $i = 0; $i < $a.length /* NullPointerException here */; $i++){
  Cookie c = $a[$i];
}best regards,
mus

  • Request dispatcher method--help needs

    Hi,
    I used request dispatcher method to redirect the from one servlet to another servlet.But when i use get method it is functioning well.
    But when i use post method it is giving error...
    I need to use post method...
    How can it possible..
    Thanks,
    Babu B

    you have code for request.RequestDispatcher.forward(""); method in both doPost and
    doGet methods for the servlet. However your initial form is not set with method
    to POST.
    By default the method is GET and it will execute code in doGet and not code in
    doPost() method. so in your first form use method as POST instead of keeping
    it to default i.e no method specified.
    let me know where are you using RequestDispatcher.
    //rohit

  • Request dispatcher vs redirect

    if there is the request dispatcher already,
              then what exactly is the point of having response.sendRedirect(url)
              is there any situation in which one should use sendRedirect over using the
              request dispatcher?
              thanks
              -Tao
              Tao Ge
              Software Engineer
              [email protected]
              (310) 883-1837
              NextEngine, Inc.
              401 Wilshire Blvd., Ninth Floor
              Santa Monica, California 90401
              This email is intended only for the use of the individual or entity to which
              it is addressed and contains information that is privileged and
              confidential. If the reader of this message is not the intended recipient
              or the employee or agent responsible for delivering the message to the
              intended recipient, you are hereby notified that any review, use, disclosure
              or distribution of this communication is strictly prohibited. If you have
              received this communication in error, please notify the sender immediately
              by reply email and destroy all copies of the original message.
              Thank you.
              

              1. You cannot forward to a file thats not this server. But you can use
              sendRedirect
              2. By using sendRedirect you are also informing browser regarding change of the
              location.
              3. When you post data to server and use of browser relaod posts data back to
              server in case of dispatcher.
              Thanks,
              Kumar.
              "Tao Y. Ge" wrote:
              > if there is the request dispatcher already,
              > then what exactly is the point of having response.sendRedirect(url)
              >
              > is there any situation in which one should use sendRedirect over using the
              > request dispatcher?
              >
              > thanks
              >
              > -Tao
              >
              > --
              >
              > Tao Ge
              > Software Engineer
              > [email protected]
              > (310) 883-1837
              >
              > NextEngine, Inc.
              > 401 Wilshire Blvd., Ninth Floor
              > Santa Monica, California 90401
              >
              > ---
              > This email is intended only for the use of the individual or entity to which
              > it is addressed and contains information that is privileged and
              > confidential. If the reader of this message is not the intended recipient
              > or the employee or agent responsible for delivering the message to the
              > intended recipient, you are hereby notified that any review, use, disclosure
              > or distribution of this communication is strictly prohibited. If you have
              > received this communication in error, please notify the sender immediately
              > by reply email and destroy all copies of the original message.
              > Thank you.
              

  • Can Request Dispatcher include 2 Jsp's ??

    HI ...
    can Request Dispatcher include 2 Jsp's.....in which
    second Jsp is accessing some parameters from First Jsp....
    From my point of view , both jsp's are get compiled seperately hence
    2nd Jsp is not getting parameters from 1st Jsp..
    Any other way to solve this problem....???
    rdTop = sc.getRequestDispatcher("/Reports/top.jsp");
    rdTop.include(req,res);
    rd1 = sc.getRequestDispatcher("/Reports/MenuTrail.jsp");
    rd1.include(req,res);
    Thanks

    No Actually ,i am using include becoz Top .jsp includes our menu,& menu trail also contains our menu...i am displaying both Jsp's thru
    servlet hence i have used Include.....
    Thanks

  • Maybe you are looking for