fujinliang 发布留言 2008-10-17 00:04
AJAX和Servlet连不上
sendRequest.html:
<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
send.html 请在下面的文本框中输入您的兴趣爱好:
send.java:
package test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class send extends HttpServlet {
/**
* Constructor of the object.
*/
public send() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml;charset=gb2312");
String text1=new String(request.getParameter("text1").getBytes("8859_1"));
String text2=new String(request.getParameter("text2").getBytes("8859_1"));
String text3=new String(request.getParameter("text3").getBytes("8859_1"));
String row1="";
String row2="";
String row3="";
if(!text1.equals(""))
{
row1="
| 1 | "+text1+" |
";
}
if(!text2.equals(""))
{
row2="
| 2 | "+text2+" |
";
}
if(!text3.equals(""))
{
row1="
| 3 | "+text3+" |
";
}
String responseText="
";
PrintWriter out = response.getWriter();
out.println(responseText);
out.flush();
out.close();
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
/**
* Initialization of the servlet.
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
高手看哈怎么联不上啊,,,没反应???????
页: [1]