Request Dispatcher

Hi,
I am trying to forward information from a servlet to a jsp, but the servlet fails with an exception,
java.lang.OutOfMemoryError: unable to create new native thread
This is what i am doing in my servlet....
String msg = "test";
req.setAttribute("msg",msg);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/displayMsg.jsp");
if (dispatcher != null)
dispatcher.forward(req, res);
else
res.sendError(res.SC_NO_CONTENT);
please help
N

Hi
From what I can see, the problem could be with the OS settings. Sometimes the maximum number of threads that a process can spawn is reached causing this error. For this you have to talk to the System Administator for the particular OS & for the particular Application Server that you may be using.
Assuming that path provided to the RequestDispatcher is correct. it is difficult to see any other error from the code you have provided.
What you can do is this:
1. Deploy a stripped down version of your application with just one servlet and one JSP. See if you can run it successfully.
2. If you are still getting the error - Log the execution with either simple console prints or to a Log file. Check to see if the requestdispatcher object is not null and also try to note at what point the exception is thrown.
Once you have this information the task of identifying the problem will become easier.
Keep me posted.
Good Luck!
Eshwar Rao
Developer Technical Support
Sun microsystems inc
http://www.sun.com/developers/support

Similar Messages

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

  • 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

  • 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 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
              > >
              > >
              

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

  • 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

  • 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

  • Problem with using Request dispatcher in my login,jspx

    Hi
    I am using Jdev 11g and new to adf.
    I am trying to work with adf security.
    I designed a login.jspx page and loginproxy.jspx accoridng to the following link
    http://groundside.com/blog/DuncanMills.php?title=j2ee_security_a_jsf_based_login_form&more=1&c=1&tb=1&pb=1
    I have added this code in login.java
         ExternalContext ectx =    FacesContext.getCurrentInstance().getExternalContext();
         HttpServletRequest request =    (HttpServletRequest)ectx.getRequest();
         HttpServletResponse response =    (HttpServletResponse)ectx.getResponse();
         RequestDispatcher dispatcher =   request.getRequestDispatcher("loginnew.jspx");
    RequestDispatcher dispatcher =   request.getRequestDispatcher("j_security_check");
        request.setAttribute("j_username", username);
        request.setAttribute("j_password", password);
         dispatcher.forward(request,response);
    When it tries to execute dispatch statement, it goes in an infinite loop and finally gets me a stack overflow error and also in the cosole it prints series of exceptions like
    ActionListenerImpl><processAction> javax.servlet.ServletException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class oracle.adf.controller.ControllerException
    javax.faces.el.EvaluationException: javax.servlet.ServletException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class oracle.adf.controller.ControllerExceptionI have to validate the user against database hence i created a login.jspx with a backing bean so that i can access the username and password and validate the credentials against db and redirect user to the appropriate page.
    The functionality i want to implement is very simple but i just cant get it to work using adf security.
    any help is highly appreciated.
    thanks
    at

    Hi Pedja,
    Thanks for the prompt reply.
    I have been following the link you mentioned to create ADF security and successfully implementedthe first part where if i directly give any internal page url it redirects me back to login page.
    Instead of using weblogic-sql authenticator, i wanted to manually authenticate the user in loginbean.java where i check the username passowrd against the db.
    I had also implemented the method to access username,password mentioned in the following thread
    Re: ADF security on my jspx  page as login page
    Insted of using authentication.login, i am calling the db method to do the validation.
    The thing is after my db validation it does redirect me to the success page(menu.jspx). but when i click links on menu.jspx it redirects me back to login page.
    so i understand that user is not yet set in the session.
    I am stuck at the point how do i code the login.jspx, currently my login.jspx does not have any j_security_check and i think this is what is creating the problem.
    while searching for adding jsecurity in jspx i landed on the blog of 2006 and started using that.
    Can you please point me to some link which explains how to code login.jspx , i have been trying hard for couple of days.
    Thanks again
    ash

  • Request Dispatcher error when forwarding

    hi all,
    I am using tomcat 4.1.24 and jdk1.3.1. I am having one servlet and one jsp. Servlet handles the submitted form and then for presentation logic it sends request to jsp page. I have servlet mapping properly defined in the web.xml and servlet url is /servlet/UploadImage. In this servlet I have used Requestdispatcher for forwarding the request to the jsp page the jsp page url is /jsp/ScanMessage.jsp. But while request is getting forwarded its throwing the exception as follows. I have not written any statement called out.println() in the servlet, even I am not geting object of PrintStream or Writer.
    Please Help me.
    Regards
    vivek
    The exception is
    2003-09-16 10:32:50 ApplicationDispatcher[] Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
    at UploadImage.processRequest(UploadImage.java:91)
    at UploadImage.doPost(UploadImage.java:105)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:466)
    at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:585)
    at java.lang.Thread.run(Thread.java:479)
    ----- Root Cause -----
    javax.servlet.ServletException: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
    at org.apache.jsp.ScanMessage_jsp._jspService(ScanMessage_jsp.java:506)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
    at UploadImage.processRequest(UploadImage.java:91)
    at UploadImage.doPost(UploadImage.java:105)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:466)
    at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:585)
    at java.lang.Thread.run(Thread.java:479)

    * Servlet.java
    * Created on August 28, 2003, 11:09 AM
    import javax.servlet.*;
    import javax.servlet.http.*;
    import post.util.PropertyFile;
    import post.beans.ImageFiles;
    import java.io.File;
    import java.io.IOException;
    import com.oreilly.servlet.*;
    * @author vivek
    * @version
    public class UploadImage extends HttpServlet
    /** Initializes the servlet.
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    /** Destroys the servlet.
    public void destroy()
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException
    try
    HttpSession session = request.getSession();
    String userId = (String)session.getAttribute("LoginID");
    String sessionId = (String)session.getId();
    String rootPath = PropertyFile.getProperty("RootDirectoryPath");
    String uploadDirectoryPath = PropertyFile.getProperty("MailUploadDirectory");
    String path = rootPath + "/" + uploadDirectoryPath + "/" + userId + "/" + sessionId + "/";
    File filePath = new File(path);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/jsp/ScanMessage.jsp");
    if(!filePath.exists())
    filePath.mkdirs();
    MultipartRequest fileRequest=null;
    try
    System.out.println("Brfore file saving");
    fileRequest = new MultipartRequest(request,path.trim(),2*1024*1024);
    System.out.println("Brfore file saving");
    catch(IOException ioe)
    request.setAttribute("ReturnedValue","MaximumSizeReached");
    dispatcher.forward(request,response);
    java.util.Enumeration uploadedFiles = fileRequest.getFileNames();
    String file = fileRequest.getFilesystemName((String) uploadedFiles.nextElement());
    System.out.println(file);
    if(file != null)
    ImageFiles files = (ImageFiles)session.getAttribute("UploadedImages");
    if(files == null)
    files = new ImageFiles();
    files.setFilePath(path);
    files.add(file);
    if(session.getAttribute("UploadedImages") == null)
    session.setAttribute("UploadedImages",files);
    System.out.println("added UploadedImages to session");
    request.setAttribute("ReturnedValue","Done");
    dispatcher.forward(request,response); //here the exception is thrown
    catch(Exception e)
    e.printStackTrace();
    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";

  • Request Dispatcher question

    Hi all,
    I have a simple question based on RequestDispatcher.
    When we dispatch a file in our servlet, where should we place RequestDispatcher --- Within try block or after try, catch block as defined in this program
    Please see the coding/program---------------
    // import all necessary packages
    public class SimpleServlet extends HttpServlet
    public void doGet()throws ServletException,IOException
    try
    Here I am retrieving data from database and then store them into bean,and doing some coding.
    This Servlet will call MyJsp.jsp file.
    dispatch="/jsp/MyJsp.jsp";
    Should we define RequestDispatcher here ?
    catch
    // OR here---------
    RequestDispatcher dispatcher=request.getRequestDispatcher(dispatch)
    dispatcher.forward(request,response);
    } // end doGet() method
    } // end class
    Thanks
    amitindia

    Hi,
    It`s better to use outside try{}catch{} block if you forward to a page based on some condition like..
    try{
    if(i.equals("soemthing")){
    dispatch="/jsp/MyJsp.jsp";
    else{
    dispatch="/jsp/Error.jsp";
    catch{}
    RequestDispatcher dispatcher=request.getRequestDispatcher(dispatch)
    dispatcher.forward(request,response);
    OR if u`r going to forward to a single page whatever be the condition then you can use Dipatch inside the try{} block itself.
    regards,
    Saravanan

  • Request Dispatching

    Hi,
    How can i dispatch the request that is coming to my servlet (or any other web web component) to an external link (out side my context) like "http://www.google.com" after setting a header variable.
    i have tried wrapping the request and using the RequestDispatcher but it seems that its not working for external links.
    Thanks,

    Of course it's not working for external links. Servlet is enclosed in a servlet container (a sort of a sandbox) so how could it dispatch the incoming request to the external server? Also look at the docs:
    "Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server".
    Google for "java proxy servlet", and implement one of the found solutions.

Maybe you are looking for

  • Powerbook -can't start up in single user mode or from CD-why?

    My daughter was gifted a Powerbook (15"). I've upgraded it to 10.5.8. It has enough speed, (1.67 Ghz), 2 gigs RAM- but it is a sticky little machine- it freezes a lot. Froze twice during the upgrade, froze once during login, Froze once while trying t

  • Noise problem with moving bitmaps

    I'm having trouble with the most recent Flash player (9,0,45,0). When displaying moving bitmaps, the player sometimes shows horizontal noise lines across the image. This doesn't happen on all platforms, but it does happen on my customers', so I've go

  • Want to change standard iw72 report. help require.

    IW72 - sap standard report. to dispaly service order details I want to display SalesOrder no. in IW72. Please give me the link between sale order and service order.

  • I want to switch apple store

    How can I switch stores from UK to Spain

  • Problem in my nokia 5800 Xm

    Hi, I bought my nokia 5800 the last 2 weeks and i realy love it...... but i have this problem that the memory content keep Disappear my music, photos, applecations, games, videos and every thing in the memory PS1: the content disappear in itself and