Calling second servlet from first servlet

I need to call a servlet from a servlet.
I need to call the specific doGet method of servlet 2 from
servlet 1. I also need to return the control to servlet 1
after servlet 2 done its job.
I did it now by creating a new instance of servlet 2 from servlet1
and then call the doGet method like
in servlet1 : Servlet2 serv2 = new Servlet2();
I really don't like this idea of creating a new instance in servlet 1.
Any thoughts/idea/comments would be appreciated.

request.getRequestDispatcher("path/to/otherServlet").forward(request, response);
or
request.getRequestDispatcher("path/to/otherServlet").include(request, response);will do what you are looking for. See the API documentation on details. Basically the difference is that forward gives FULL control (including that of the headers) to the invoked servlet while include mearly "includes" the results.

Similar Messages

  • What is the best way to call a servlet from another servlet?

    I have a project with 9 servlets (class project). The way I have been moving from servlet to servlet is like this
    doPost(...)
    {      response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>Functions</title>");
    out.println(f"<form name=frm6 method=post action=/servlet2");
    out.println("<input type=submit name='btn' value='servlet2'>");
    out.println("</form>");
    So I have these 9 servlets - I call any 8 of them from the first servlet so I have 8 buttons on 8 forms <form=frm1, frm2, ...frm8 method = post...> But when I bring up the first servlet only 6 buttons show up. I was thinking about using hyperlinks instead, but I would like to do this with buttons. I wanted to do this with javascript and the location object, but I was advised to use jsp. I just want to move from one servlet to the next. Any suggestions appreciated for the best/preferred method for moving from one servlet to the next.
    Thanks

    I think you may need some clarification of terminology etc..
    First off, JSP isn't an alternative to javascript, it's an alternative to coding a servlet. A JSP is a mixture of java code and HTML and is translated into a servlet by the system. JSPs are primarilly for generating HTML pages with variable content. JSPs very frequently generate HTML which includes Javascript.
    You probably shouldn't think of what you're doing as one servlet invoking another, that does happen; a servlet can transfer an transaction to another servlet or JSP. In fact it's standard practice that a servlet does the logical stuff (like interpretting form data) then transfers to a JSP to generate the response page. However in this case it's the browser that can invoke one of the 8 servlets, the first servlet merely creates the page from which they are invoked.
    It's not obvious why only some of your buttons are showing up. In a case like this use the "view source" option on your browser to find out what HTML the servlet is actually delivering. What's wrong should be evident from that.
    You can put a hyperlink arround a button, or an image. Mostly people turn up their noses at the buttons supplied by HTML and use their own images for buttons. You
    can do somthing like this:
    <img src="/images/button3.png" border="0">
    (Of course this arrives as a GET transaction not a POST).
    Or you can do a bit of javascript like:
    <img src="/images/button3.png" style="Cursor: pointer;"
    onclick="document.locations.href='/servlet3';">

  • How to call a Applet from a servlet and vice versa...?

    Hi all
    Can anyone help me how to call a applet from a servlet and vice versa. When the applet is called it should contact the database (oracle8i) and get the data. When i submit the applet form the data in the applet should be saved in the database.
    Thanks in advance
    Kamalakannan

    Sweep is correct about requestDispatcher being another approach for inter-servlet delegation; the only issue that i recall with this approach is that it defaults the method of the destination servlet to the one it was called from...for example, calling servlet2 from within servlet1.post() resulted in the dispatcher attempting to utilize servlet2.post() - i believe that i searched for a parameterize solution to no avail :( (ended up handling the request by placing a "fake" doPost() in servlet2 that simply called servlet2.doGet())
    however, if your application is functioning correctly on your pc/webserver then the problem may be external to servlet communication (e.g. client webserver's ports not configured or blocked, missing runtime classes, etc.)
    my suggestion would be to set aside the programmatic concerns for the moment - what is the response if you open a browser on a client's machine and access the URL in question (i.e. http://clientserver:port/stefanoServlet)? If it will not respond to access in this manner then it certainly won't when your application calls for it.
    It's possible that there is a coding error but, given the info supplied, i'd start examining the environment, first. Let us know if you have any luck with the test i recommended or not (please provide abundant detail). Or, if you've found the solution then you may want to post back with a quick blub so the next person knows how to escape the trap.
    D

  • How to call a specific method in a servlet from another servlet

    Hi peeps, this post is kinda linked to my other thread but more direct !!
    I need to call a method from another servlet and retrieve info/objects from that method and manipulate them in the originating servlet .... how can I do it ?
    Assume the originating servlet is called Control and the servlet/method I want to access is DAO/login.
    I can create an object of the DAO class, say newDAO, and access the login method by newDAO.login(username, password). Then how do I get the returned info from the DAO ??
    Can I use the RequestDispatcher to INCLUDE the call to the DAO class method "login" ???
    Cheers
    Kevin

    Thanks for the reply.
    So if I have a method in my DAO class called login() and I want to call it from my control servlet, what would the syntax be ?
    getrequestdispatcher.include(newDAO.login())
    where newDAO is an instance of the class DAO, would that be correct ?? I'd simply pass the request object as a parameter in the login method and to retrieve the results of login() the requestdispatcher.include method will return whatever I set as an attribute to the request object, do I have that right ?!!!!
    Kevin

  • Calling a WS from a servlet...EndpointPort does not contain operation meta.

    Hi all,
    I'm trying to call a service from a servlet but I get an error:
    Error: Endpoint {http://com.susan/SusanWS}SusanWebServiceEndpointPort does not contain operation meta data for: LoginWebService
    ...the WS is up and running (of this I'm sure...cause I also tested it with soapui...and it works..)
    The webservice is running on a local jboss (to which i can successfully connect, and see the wsdl...).
    the servlet is running on a local tomcat (which is also ok...).
    I'm trying to call the WS like this:
    Service service = new Service();
    Call call = (Call)service.createCall();
    call.setTargetEndpointAddress( new URL( wsEndpoint ) ); //http://localhost:8080/webservices/SusanWS (the same I used in soapui...so it should be right)
    call.setOperationName( "LoginWebService"); //name of the method i want to use...
    call.addParameter( "appCode", Constants.XSD_STRING, ParameterMode.IN );
    call.addParameter( "login", Constants.XSD_STRING, ParameterMode.IN );
    call.addParameter( "passwd", Constants.XSD_STRING, ParameterMode.IN );
    //            call.setReturnType( Constants.XSD_INT ); //left this out...should be the cause...
    Object retval = call.invoke( new String[] { appCode, login, passwd} ); //appCode,login,passwd contain the strings i want to  forward as input.if I try to run it I get(in the jboss log...):
    15:41:55,594 ERROR [SOAPFaultExceptionHelper] SOAP request exception
    javax.xml.rpc.soap.SOAPFaultException: Endpoint {http://com.susan/SusanWS}SusanWebServiceEndpointPort does not contain operation meta data for: LoginWebService
    at org.jboss.ws.server.ServiceEndpointInvoker.getDispatchDestination(ServiceEndpointInvoker.java:181)
    at org.jboss.ws.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:107)
    at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:209)
    at org.jboss.ws.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:355)
    at org.jboss.ws.server.StandardEndpointServlet.doPost(StandardEndpointServlet.java:115)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.jboss.ws.server.StandardEndpointServlet.service(StandardEndpointServlet.java:76)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Thread.java:595)
    don't know if it can help...the soapui request looks like this:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://com.susan/SusanWS/types">
    <soapenv:Header/>
    <soapenv:Body>
    <typ:LoginWebService>
    <LoginInfo_1>
    <appCode>WEB_SERVICES</appCode>
    <login>root</login>
    <passwd>root</passwd>
    </LoginInfo_1>
    </typ:LoginWebService>
    </soapenv:Body>
    </soapenv:Envelope>
    anybody has an idea of what I'm doing wrong?
    Edited by: Turbo-555 on Mar 18, 2009 8:36 AM

    if I change the code with:
    //call.setOperationName( wsMethod );
    call.setOperationName( new QName("http://com.susan/SusanWS",wsMethod)); //http://com.susan/SusanWS is the targetnamespace...the error changes into:
    16:55:21,051 ERROR [SOAPFaultExceptionHelper] SOAP request exception
    javax.xml.rpc.JAXRPCException: Cannot find child element: {http://com.susan/SusanWS/types}LoginWebService
    at org.jboss.ws.binding.soap.SOAPBindingProvider.getParameterFromMessage(SOAPBindingProvider.java:799)
    at org.jboss.ws.binding.soap.SOAPBindingProvider.unbindRequestMessage(SOAPBindingProvider.java:282)
    at org.jboss.ws.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:112)
    at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:209)
    at org.jboss.ws.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:355)
    at org.jboss.ws.server.StandardEndpointServlet.doPost(StandardEndpointServlet.java:115)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.jboss.ws.server.StandardEndpointServlet.service(StandardEndpointServlet.java:76)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Thread.java:595)

  • Calling a servlet from a servlet?

    Is it possible to call one servlet from another servlet?

    You should use servlets to process requests. If what you're asking for is to execute a piece of logic within a servlet before its finished processing the request, then you should consider using a regular java class instead of a servlet. If you just want to send the request information to another servlet you can use getRequestDipatcher().forward(..) method. Keep in mind that by doing so you'll interupt the current servlet.
    Regards,
    D.

  • Calling a servlet from another servlet?

    Hi
    I would like to know that how can I call one Servlet from another Servlet. I have tried getServlet() method of ServletContext but it has been deprecated. I want to call a specific method of the other Servlet, is there any other way?
    Thanks

    I should have seen it from your previous post :(
    Code of Servlet 1:
    public void doGet(HttpServletRequest request,
    HttpServletResponse response) throws
    ServletException, IOException
    RequestDispatcher rDispatch = null ;
    rDispatch = getServletConfig
    ().getServletContext().getRequestDispatcher
    ("/Servlet2") ;
    rDispatch.forward(request, response) ;
    System.out.println("Back in 1");
    I assume Servlets 1and 2 are in same web app and you've mapped your servlet2 to /Servlet2 in your web.xml
    make it as
    rDispatch = request.getRequestDispatcher("/Servlet2");
    rDispatch.forward(request,response);
    Nothin's wrong with yer servlet2

  • Can I call a "function" from a servlet?

    A few of my servlets need to perform about the same computations (have large sections of identical code).
    It would save some disk space to be able to call a procedure from different servlets.
    Can this be done? How?
    Thank you all.

    A few of my servlets need to perform about the same
    computations (have large sections of identical code).
    It would save some disk space to be able to call a
    procedure from different servlets.
    Can this be done? How?This wouldn't be the way to do it.
    Since Java is an object oriented programming language, you should use it's concepts to implement a 'basic' class and than extend it. This means: Create a class that contains the basic procedures (you will never create an instance of this class) and then create all the serlvet classes by extending the 'mother' class. Like this you have the common code once in the 'mother' class and the specific code in the specific servlets.

  • Different ways to invoke a servlet from another servlets?

    Hello,
    I am a bit confused today. I was thinking about all the ways by which I can invoke a servlet from another servlets. I know it can be done by creating an instance of the 2nd servlet in the 1st one. Is there any other way? such as say.... RequestDispatcher perhaps?
    Here is an example to illustrate my point. I have a login.jsp which submits to login.do. login.do search through database and first authenticate email and then the corresponding password. Now its time for displayGame.do. So here how do i do? if it was a displayGame.jsp then i could have used Redirection or Forward but when it is servlets? Can I still go for Redirection or Forward??
    Thank you for reading this confused post. :-)

    if it was a displayGame.jsp then i could have used Redirection or Forward but when it is servlets?Question: do you know what a JSP becomes when you first run it?
    Answer: a servlet.
    So yes, you can use a RequestDispatcher to forward/redirect to a servlet OR a JSP, whatever you like.

  • How can i call a servlet from a servlet ?

    Hello,
    Can i call a Servlet from within a Servlet ?
    and is it "right thing" to Do ?
    Thanks

    JMO, but I wouldn't do it like this.
    Don't have a remote object like a servlet doing database queries for your app. That will mean TWO network hops for every query if the database resides on another machine. The network is the biggest bottleneck you've got.
    Write a JavaBean that does the database stuff for you and just have the first servlet instantiate it when it needs it. A Bean has a better chance of being reused, too. Write a TableGateway or DAO for your object.
    Or write an EJB to do it.
    The only time I've done a servlet-to-servlet connection like that was for one servlet running in a DMZ that would authenticate a user and then forward the request to another servlet running inside the second firewall.
    I wouldn't encapsulate database query logic in a servlet like that. JMO - MOD

  • Calling one Servlet from another servlet

              First servlet...............>
              package javaservlets.samples;
              import javax.servlet.*;
              import javax.servlet.http.*;
              public class TableElements extends HttpServlet{
                   public void doGet(HttpServletRequest request,HttpServletResponse response)
                   throws ServletException,IOException{
                        response.setContentType("text/plain");
                        try{
                             RequestDispatcher rd = getServletContext().getRequestDispatcher("/TableFilter");
                             if(request==null){
                                  System.out.println("Request null...");
                                  System.exit(0);
                             if(response == null){
                                  System.out.println("Response null...");
                                  System.exit(0);
                             if(request!=null&&response != null){
                             System.out.println("Both are not null...");
                             rd.forward(request,response);
                        }catch(ServletException se){
                             se.printStackTrace();
                        }catch(IOException ioe){
                             ioe.printStackTrace();
              Second Servlet..............>
              package javaservlets.samples;
              import javax.servlet.*;
              import javax.servlet.http.*;
              public class TableFilters extends HttpServlet{
                   public void service(HttpServletRequest request,HttpServletResponse response)
                   throws IOException,ServletException{
                        String type = request.getContentType();
                        System.out.println("type : "+type);
              from the TableElement servlet just I am calling the TableFilter servlet and in
              the TableFilter I am trying to print the request content type. But I am getting
              NULL. i was supposed to get "TEXT/PLAIN".
              can any one tell what is the problem.
              very urgent.
              thanx in advance
              

    Your example seems to assume that the reponse of the first servlet becomes
              the request in the second servlet let this is not so. After the forward the
              request and response obejcts are the same as before the forward, except the
              referer attribute is changed.
              "Gururaj Kosigi" <[email protected]> wrote in message
              news:[email protected]...
              >
              > First servlet...............>
              >
              > package javaservlets.samples;
              >
              > import javax.servlet.*;
              > import javax.servlet.http.*;
              >
              >
              > public class TableElements extends HttpServlet{
              >
              >
              >
              > public void doGet(HttpServletRequest request,HttpServletResponse response)
              > throws ServletException,IOException{
              >
              > response.setContentType("text/plain");
              >
              >
              > try{
              >
              > RequestDispatcher rd =
              getServletContext().getRequestDispatcher("/TableFilter");
              >
              > if(request==null){
              > System.out.println("Request null...");
              > System.exit(0);
              > }
              > if(response == null){
              > System.out.println("Response null...");
              > System.exit(0);
              > }
              > if(request!=null&&response != null){
              > System.out.println("Both are not null...");
              > }
              >
              > rd.forward(request,response);
              > }catch(ServletException se){
              > se.printStackTrace();
              >
              > }catch(IOException ioe){
              > ioe.printStackTrace();
              >
              > }
              >
              > }
              > }
              >
              > Second Servlet..............>
              >
              > package javaservlets.samples;
              >
              > import javax.servlet.*;
              > import javax.servlet.http.*;
              >
              >
              > public class TableFilters extends HttpServlet{
              >
              > public void service(HttpServletRequest request,HttpServletResponse
              response)
              > throws IOException,ServletException{
              >
              >
              > String type = request.getContentType();
              > System.out.println("type : "+type);
              >
              > }
              > }
              >
              > from the TableElement servlet just I am calling the TableFilter servlet
              and in
              > the TableFilter I am trying to print the request content type. But I am
              getting
              > NULL. i was supposed to get "TEXT/PLAIN".
              >
              > can any one tell what is the problem.
              > very urgent.
              >
              > thanx in advance
              

  • Calling another servlet from a servlet

    I'm working on a servlet and would like to know how to
    call another servlet, by clicking on a form button
    or a hyperlink that was generated from the first servlet,
    is it only possible if the second servlet is called
    in an shtml page? Can you please give me an example
    of how to do this not using shtml pages?
    (I'm working with JDeveloper 2.0)
    When will the book be out for JDeveloper 2.0?
    We're also having problems deploying the servlet
    to the Java Web Server (1.1.3)
    It seems to have a problem connecting to the database.
    We get the first page of the servlet but the
    second page is generated from the doPost()
    and connects to the database using oracle JDBC thin
    gives a http 500 internal server error ,
    and we followed the instructions from JDeveloper
    can the problem be caused from the connection string that
    I used in the servlet:
    Class.forName("oracle.jdbc.driver.OracleDriver");
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@(description=(address=
    (host=10.10.10.53)(protocol=tcp)(port=1521))
    (connect_data=(sid=OR8A)))",
    "im_dev","im_dev");
    or the configuration of the web server?
    (web server: Solaris 2.7 running on Intel)
    null

    Hi
    The sample acme video demo in JDeveloper does something similar.
    It has main Servlet "WebAppServlet.java" which overides the
    doPost and doGet methods and this methods calls someother java
    classes do perform some specific business logic which return a
    html page in a String format to "WebAppServlet.java".
    Open the samples directory in JDEveloper 2.0 with WebApp_81.jws
    to look at the source code.
    Steps to run the sample are included in the help system.
    regards
    argyro (guest) wrote:
    : I'm working on a servlet and would like to know how to
    : call another servlet, by clicking on a form button
    : or a hyperlink that was generated from the first servlet,
    : is it only possible if the second servlet is called
    : in an shtml page? Can you please give me an example
    : of how to do this not using shtml pages?
    : (I'm working with JDeveloper 2.0)
    : When will the book be out for JDeveloper 2.0?
    : We're also having problems deploying the servlet
    : to the Java Web Server (1.1.3)
    : It seems to have a problem connecting to the database.
    : We get the first page of the servlet but the
    : second page is generated from the doPost()
    : and connects to the database using oracle JDBC thin
    : gives a http 500 internal server error ,
    : and we followed the instructions from JDeveloper
    : can the problem be caused from the connection string that
    : I used in the servlet:
    : Class.forName("oracle.jdbc.driver.OracleDriver");
    : DriverManager.registerDriver(
    : new oracle.jdbc.driver.OracleDriver());
    : con = DriverManager.getConnection(
    : "jdbc:oracle:thin:@(description=(address=
    : (host=10.10.10.53)(protocol=tcp)(port=1521))
    : (connect_data=(sid=OR8A)))",
    : "im_dev","im_dev");
    : or the configuration of the web server?
    : (web server: Solaris 2.7 running on Intel)
    null

  • How to call a servlet from another servlet

    hi everybody,
    i have a problem, i have to call one servlet from another one.
    Everything works on my pc, but when i install the application on the customer's server i got an error about an Uknown URL followed by the name of the machine.
    Wjat i do is the folloqing :
    String urlString = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+servletName;
    URL url = new URL(urlString);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    the variable servletName is the name of the servlet i have to call.
    Is there another way to call the servlet ?
    All the servlet are installed in the same server.
    Any suggestion ?
    Cheers.
    Stefano

    Sweep is correct about requestDispatcher being another approach for inter-servlet delegation; the only issue that i recall with this approach is that it defaults the method of the destination servlet to the one it was called from...for example, calling servlet2 from within servlet1.post() resulted in the dispatcher attempting to utilize servlet2.post() - i believe that i searched for a parameterize solution to no avail :( (ended up handling the request by placing a "fake" doPost() in servlet2 that simply called servlet2.doGet())
    however, if your application is functioning correctly on your pc/webserver then the problem may be external to servlet communication (e.g. client webserver's ports not configured or blocked, missing runtime classes, etc.)
    my suggestion would be to set aside the programmatic concerns for the moment - what is the response if you open a browser on a client's machine and access the URL in question (i.e. http://clientserver:port/stefanoServlet)? If it will not respond to access in this manner then it certainly won't when your application calls for it.
    It's possible that there is a coding error but, given the info supplied, i'd start examining the environment, first. Let us know if you have any luck with the test i recommended or not (please provide abundant detail). Or, if you've found the solution then you may want to post back with a quick blub so the next person knows how to escape the trap.
    D

  • How can I call an ".asp" from a Servlet?

    I want to make a call to an asp page from my servlet. If i use the conventional way of doing it as follows:
    RequestDispatcher rd = getServletContext().getRequestDispatcher("http://localhost:8080/abc.asp");
    rd.forward(request, response)
    It gives me IllegalArgumentException saying that the "Path must be absolute". And if i give the relative path like
    RequestDispatcher rd = getServletContext().getRequestDispatcher("/abc.asp");
    rd.forward(request, response)
    In this case it takes me to the asp page, but gives some ClassNotFoundException - images.
    I do not understand what class it is looking for and where to get that?
    So Why am i not able to call an ASP from Servlet, Any clue??

    What are you trying to accomplish? A redirect is one of the only ways to successfully go from a Servlet to an ASP. For example:response.sendRedirect("http://server:9090/abc.asp?name=value");This is mainly because when you forward, your actually sending the request and response objects under the current servlet context to be processed by another JSP/servlet in the same (sometimes cross) context.
    When interacting with ASP's your actually communicating between web containers (one which is Java based the other VB based).
    When you use:RequestDispatcher rd = getServletContext().getRequestDispatcher("http://localhost:8080/abc.asp");
    rd.forward(request, response) Your telling the servlet to send it's contents outside the web container where they cannot exist as such (even though you are pointing to your own JSP server, it's the "http://" that makes it assume your trying to get out).
    Using: RequestDispatcher rd = getServletContext().getRequestDispatcher("/abc.asp");
    rd.forward(request, response) is fine but what is processing your asp in your Java Web Server?
    The best way to mix JSP/Servlets with ASP (in my opinion others may debate it if they please) is using messaging like XML. Trying to share sessions between ASP and Java is quite messy and to much effort for a 1 to 1 communication option.
    Back to an earlier question, what is processing your asp files in the Java web server? If you have something processing them (like ChilliSoft) then check the docs to see if it supports session sharing between JSP/Servlet - ASP.
    Anthony

  • Problem in calling JSP page from a servlet

    can anyone please tell me how to call a JSP from servlet?
    My code is:
    ServletContext sc = this.getServletContext();
                                                 RequestDispatcher rd = sc.getRequestDispatcher("./Welcome.jsp");
                                                 if (rd !=null)
                                                      try
                                                           rd.forward(req, res);
                                                      catch (Exception e)
                                                           sc.log("---------------Problem invoking JSP.------------------", e);
    I n the browser when i call this servlet it gives error-404.
    NOT Found.
    please help.

    I would try to change "./Welcome.jsp" to "/Welcome.jsp". I'm not sure what that period will do.
    Are you able to access that JSP directly from your browser (even if it's not designed to be accessed that way)? If not, then you have some other problem.
    When you say you get a 404 when you access the servlet, is that when you access the servlet, or when it tries to forward to the JSP? If you get the 404 when you access the servlet, perhaps your servlet-mapping to the servlet is invalid.

Maybe you are looking for

  • My dowload arrow on the top right has disappeared, how do i get it back

    Please help with returning my dowload arrow on the top right hand corner, when I open safari, it has disdapeared.

  • G/L Account Balances

    Hello Dear Friends, I need G/L account Balances list including below datas. can you help me? thank you very much in advance... Reporting Period: 2011 January-March G/L Accounts  "Balance Carryforward"       "Debit Reporting Period"     "CreditReporti

  • Netui anchor tag in netui:form

    I have some code like following: <netui:form action="action1" > <netui:anchor action="action2">Check</netui:anchor> </netui:form> Action1 and action2 willl be finally redirected to the same JSP(for example one.jsp). The weird thing is that: according

  • Install oracle 10g on mac os

    Hi I just interested in try to install Oracle Database 10g Release 2 (10.2.0.4.0) on my Mac Book Pro http://www.oracle.com/technetwork/database/10204macsoft-x86-64-092720.html I downloaded it and try, but it seem doesn't work. Will it must install it

  • I want to know course details for oracle financials

    Hi all I want to know course details for oracle financials. Working as a software engineer with banking domain experience.. my contact no. :- 9740388745 mail-id :- [email protected]