tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sonia Galilea Varea <gali...@ebro.cps.unizar.es>
Subject call a servlet from another servlet
Date Tue, 06 Nov 2001 08:31:28 GMT
Hi,

    I have a servlet derived from HttpServlet and when its init() method
is executed, I have to call another servlet to begin to execute too. The
call to that other servlet is via:

    URL myURL  = new URL("   ...............URL of the other
servlet...............    ");
    URLConnection myURLConnection = myURL.openConnection();
    myURLConnection.getInputStream(); //here, the URL is executed...

The problem is when, in web.xml file, I write
<load-on-startup>0</load-on-startup>    so that the first servlet begins
executing when Tomcat begins.
If I call the first servlet from the URL of the navigator, it works OK.
But if I want the servlet to execute its init() method when Tomcat
starts, when Tomcat is going to execute
myURLConnection.getInputStream();         the next exception is ocurred:

java.net.ConnectionException: Connection refused: no further information

    at java.net.PlainSocketImpl.socketConnection(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:312)
    at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
    at java.net.Socket.(init)(Socket.java:273)
    at java.net.Socket.(init)(Socket.java:100)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:50)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:331)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:517)
    at sun.net.www.http.HttpClient.(init)(HttpClient.java:267)
    at sun.net.www.http.HttpClient.(init)(HttpClient.java:277)
    at sun.net.www.http.HttpClient.New(HttpClient.java:289)
    at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:379)

    at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:472)

    .......
    at
org.apache.tomcat.core.LoadOnStartupInterceptor.contextInit(LoadOnStartupInterceptor.java:130)

    at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:491)

    at
org.apache.tomcat.core.ContextManager.init(ContextManager.java:453)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:195)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)


I need the first servlet call the second one and this first servlet is
executed (its init() method) when Tomcat starts, not when the servlet
receives its first request. How can I do it?

Thanks.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message