关于Applet与servlet通讯问题,高手请进,在线等!
//servlet端的代码
public class PERTSaveServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, java.io.IOException {
ObjectInputStream inputFromApplet = null;
PERTInfo pertInfo = null;
PrintWriter out = null;
BufferedReader inTest = null;
try {
inputFromApplet = new ObjectInputStream(request.getInputStream());
//pertInfo 是一个序列化的对象
pertInfo = (PERTInfo) inputFromApplet.readObject();
inputFromApplet.close();
if (pertInfo != null) {
...
}
// send back a confirmation message to the applet
out = new PrintWriter(response.getOutputStream());
response.setContentType("text/plain");
out.println("confirmed");
out.flush();
out.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
//applet端的代码
protected void sendValueToServlet() {
ObjectOutputStream outputToServlet = null;
try {
// connect to the servlet
URL studentDBservlet = new URL(contextPath + "/PERTSaveServlet");
URLConnection servletConnection = studentDBservlet.openConnection();
// inform the connection that we will send output and accept input
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
// Don't used a cached version of URL connection.
servletConnection.setUseCaches(false);
// Specify the content type that we will send binary data
servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
// send the PERTInfo object to the servlet using serialization
try {
outputToServlet = new ObjectOutputStream(servletConnection.getOutputStream());
// serialize the object
outputToServlet.writeObject(pertInfo);
outputToServlet.close();
}
catch (IOException e) {
System.out.println("Error!!!");
}
// now, let's read the response from the servlet.
// this is simply a confirmation string
// readServletResponse(servletConnection);
}
catch (Exception e) {
System.out.println(e.toString());
}
}
为何servlet端接收不到数据?
我是在JBOSS4.0.4+struts环境下调试的,无任何错误提示,APPLET端是正常的,但servlet端好象一点反应都没有?
...全文
相关推荐
PCS7 - Soft Starter 3RW5 PCS7 Library V9.1
PCS7 - Soft Starter 3RW5 PCS7 Library V9.1
第2课 SQL入门之检索数据
介绍如何使用SELECT语句从表中检索一个或多个数据列
5-实验指导书_PID控制算法.docx
5-实验指导书_PID控制算法.docx
高校技术转移办公室人员如何利用平台提升技术成果的精准推介效率?.docx
高校技术转移办公室人员如何利用平台提升技术成果的精准推介效率?
产业园区运营负责人如何精准对接企业技术需求与科技成果?.docx
科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。


Java SE
