import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;public class SerAndApp extends HttpServlet{
String respData;
public void service(HttpServletRequest req,HttpServletResponse resp)
{
try
{
DataInputStream in=new DataInputStream(req.getInputStream());
resp.setContentType("application/octest-stream");
ByteArrayOutputStream byteout=new ByteArrayOutputStream();
DataOutputStream out=new DataOutputStream(byteout);
//String response=in.readUTF();
String response=in.readUTF();
out.writeUTF(response);
out.flush();
byte buf[]=byteout.toByteArray();
resp.setContentLength(buf.length);
ServletOutputStream servletout=resp.getOutputStream();
servletout.write(buf);
servletout.close();
}catch(java.io.IOException e){}
}
------------------
你贴的代码
其中
resp.setContentType("application/octest-stream");
有错
import javax.servlet.http.*;
import java.io.*;public class SerAndApp extends HttpServlet{
String respData;
public void service(HttpServletRequest req,HttpServletResponse resp)
{
try
{
DataInputStream in=new DataInputStream(req.getInputStream());
resp.setContentType("application/octest-stream");
ByteArrayOutputStream byteout=new ByteArrayOutputStream();
DataOutputStream out=new DataOutputStream(byteout);
//String response=in.readUTF();
String response=in.readUTF();
out.writeUTF(response);
out.flush();
byte buf[]=byteout.toByteArray();
resp.setContentLength(buf.length);
ServletOutputStream servletout=resp.getOutputStream();
servletout.write(buf);
servletout.close();
}catch(java.io.IOException e){}
}
------------------
你贴的代码
其中
resp.setContentType("application/octest-stream");
有错
http://www.csdn.net/expert/topicview1.asp
http://www.csdn.net/expert/TopicView.asp?id=254481