Hi, I tried to write a servlet to communicate with another servlet by
getting the second servlet's reference
using the following code. It so happened that everytime the servlet context
return null when I call
context.getServletNames() or simply context.getServelt(servletName). I'm
using JWS 2.0 + Jdk1.2.2.
The code works fine under Visual Cafe 3.0c + jdk1.2.2 environment but just
did not work under JWS 2.0.
Any idea? Thanks.
public static Servlet getServlet(String servletName,
ServletRequest req,
ServletContext context)
try
{
Servlet servlet = context.getServlet(servletName);
if(servlet != null)
{
return servlet;
}
Socket socket = new Socket(req.getServerName(),
req.getServerPort());
socket.setSoTimeout(4000);
PrintWriter out = new PrintWriter(socket.getOutputStream(),
true);
out.println("GET /servlet/" + servletName + " HTTP/1.0");
out.println();
Enumeration names = context.getServletNames();
try
{
socket.getInputStream().read();
}
catch(InterruptedIOException e)
{
out.close();
}
Servlet s = context.getServlet(servletName);
return context.getServlet(servletName);
}
catch(Exception e)
{
return null;
}
}
============================
Katrina Chiang
Member of Technical Staff
Bell Labs, Lucent Technologies
[EMAIL PROTECTED]
(650)565-7664
3180 Porter Drive
Palo Alto, CA
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html