tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eichfelder, Frank" <Frank.Eichfel...@t-systems.de>
Subject RE: call a servlet from another servlet
Date Tue, 06 Nov 2001 10:48:28 GMT
Just try it with different parameters for the <load-on-startup>-parameter
for the two servlets.
The servlet which is called via the URL should be started before the other
servlet, so it should get a lower startup-number (e.g. 1) than the other one.

I hope this works, but I didn't try it...


> -----Urspr√ľngliche Nachricht-----
> Von: Sonia Galilea Varea [mailto:galilea@ebro.cps.unizar.es]
> Gesendet am: Dienstag, 6. November 2001 09:31
> An: tomcat-user@jakarta.apache.org
> Betreff: call a servlet from another servlet
> 
> 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(HttpURLCon
> nection.java:379)
> 
>     at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(Htt
> pURLConnection.java:472)
> 
>     .......
>     at
> org.apache.tomcat.core.LoadOnStartupInterceptor.contextInit(Lo
> adOnStartupInterceptor.java:130)
> 
>     at
> org.apache.tomcat.core.ContextManager.initContext(ContextManag
> er.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.
> 
> 

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message