登录 | 首页 -> 华新鲜事 -> 社会百科 | 切换到:传统版 / sForum | 树形列表
Servlet Problem, Pls help!
<<始页  [1]  末页>> 

Servlet Problem, Pls help!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");
}
[*方便面* (7-10 17:58, Long long ago)] [ 传统版 | sForum ][登录后回复]1楼


<<始页  [1]  末页>> 
登录 | 首页 -> 华新鲜事 -> 社会百科 | [刷新本页] | 切换到:传统版 / sForum