日期:2014-05-18 浏览次数:20805 次
http://localhost:8000/Serclet/test?name=qq&pwd=123
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
System.out.println("发送的内容:"+name+"#"+pwd);
request.getSession().setAttribute("name", name);
request.getSession().setAttribute("pwd", pwd);
response.sendRedirect("MyJsp.jsp");
out.flush();
out.close();
}
public static void main(String[] args) {
URL url=null;
BufferedReader budr=null;
try {
url=new URL("http://localhost:8000/Serclet/test?name=qq&pwd=123");
budr=new BufferedReader(new InputStreamReader(url.openStream()));
System.out.println("qqqqqq");
System.out.println(budr.readLine());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}