Servlet Problem, Pls help!
登录 | 论坛导航 -> 华新鲜事 -> 社会百科 | 本帖共有 1 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:*方便面* (等级:2 - 初出茅庐,发帖:65) 发表:2003-07-10 17:58:01  楼主  关注此帖
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&quot;;
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!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表
论坛导航 -> 华新鲜事 -> 社会百科 | 返回上一页 | 本主题共有 1 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码