嗨請有人幫我解決這個問題。如何在沒有HttpServletresponse的情況下發送回應請求
我有延伸的類的HttpServlet和被叫的doGet(HttpServletRequest的請求)
但是我沒有HttpServletResponse的。現在我想爲不具有即時響應於來自客戶端的請求響應我怎樣才能方法到request.Can迴應我創建能夠在使用類反射動態創建它,是他們的任何其他way..My問題的僞代碼如下
protected void doGet(HttpServletRequest request)throws ServletException, IOException {//having only request as parameter in doGet()
//Want to respond to a jsp with out having a response
//how can i create a response object if i got a HttpServletResponse response the code looks as follows
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
String name = request.getParameter("username");
String password = request.getParameter("password");
if(name.equals("James")&& password.equals("abc")){
response.sendRedirect("result.jsp");
}
else{
pw.println("u r not a valid user");
}
}
開始從過去的1周張貼問題...... !!!! – babuchitti
是啊會嘗試格式...謝謝! – babuchitti