Servlet Problem, Pls help!
所在版块:社会百科 发贴时间:2003-07-10 17:58

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
Now i have a standalone application which will call initHttpConn() method on runtime. Inside initHttpConn() method, it will connect to a servlet called "ServletProxy" to send and receive binary messages (actually object instances).

Now the problem is it seems that method initHttpConn() always fails to connect to the servlet. There is no printout on the server console. Does any one know why? THanks a lot!

I am sure that the tomcat server is up, the servlet resource is located correctly


=====================================
private void initHttpConn() {
String location = "http://localhost/servlet/ServletProxy";
URL urlOfServlet = new URL( location );
servletConnection = urlOfServlet.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);
servletConnection.setRequestProperty ("Content-Type", "application/octet-stream");
System.out.println ("initHttpConn call finished.");
o = new Object[] { "dummyText" };
ObjectOutputStream outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
outputToServlet.writeObject(o);
outputToServlet.flush();
outputToServlet.close();

}

ServletProxy.java Code Fragment:
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
System.out.println("doGet called");
}

public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
System.out.println("doPost called");
}
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

Put your OWN COOL signature here!