943,960 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 2295
  • JSP RSS
Jul 22nd, 2008
0

URL in address bar,didnt change but the view is correct

Expand Post »
I'm building small application, im kinda newbie in jsp..I use the MVC n servlets concepts..
My problem is after from servlets, the page i want to go (change to another place) cannot shown in the address bar correctly(the addressbar still showing the servlet page), but the view is exactly d same with the page i want to go..

I create a login page in file main.jsp, i send the data to ControlIndex servlet, n if login success go to mgmtActivity.jsp, all the error things while login i saved in the list errors.

This is my servlet code:
JSP Syntax (Toggle Plain Text)
  1. public class ControlIndex extends HttpServlet {
  2. private List errors = new Vector();
  3. private HttpSession session;
  4.  
  5. protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  6. throws ServletException, IOException {
  7. response.setContentType("text/html;charset=UTF-8");
  8. PrintWriter out = response.getWriter();
  9. out.close();
  10. }
  11.  
  12. protected void doGet(HttpServletRequest request, HttpServletResponse response)
  13. throws ServletException, IOException {
  14. doPost(request, response);
  15. }
  16.  
  17. protected void doPost(HttpServletRequest request, HttpServletResponse response)
  18. throws ServletException, IOException {
  19. session = request.getSession();
  20. errors.clear();
  21.  
  22. boolean statusLogin = false;
  23. String aksi = request.getParameter("aksi");
  24.  
  25. if (aksi.equals("login")){
  26. String username = request.getParameter("username");
  27. String password = request.getParameter("password");
  28. User user = null;
  29. // input validation
  30. if ((username == null) || !username.trim().matches("^[a-zA-Z]+$")){
  31. errors.add("Username cannot contains white space or non alphabetic characters.");
  32. }
  33. // execute
  34. if (errors.size()==0){
  35. user = User.getUser(username);
  36. if (user == null){
  37. errors.add("Cannot find those username.");
  38. } else{
  39. if (user.validatePassword(password)){
  40. statusLogin = true;
  41. } else{
  42. errors.add("Wrong password.");
  43. }
  44. }
  45. }
  46. if (statusLogin){
  47. //set session
  48. session.setAttribute("user", user);
  49. RequestDispatcher view = request.getRequestDispatcher("mgmtActivity.jsp");
  50. try{
  51. view.forward(request, response);
  52. }catch(ServletException e){
  53. e.printStackTrace();
  54. }
  55. }
  56. }else if (aksi.equals("logout")){
  57. //delete session
  58. session.setAttribute("user", null);
  59. }
  60. if (errors.size()!=0){
  61. request.setAttribute("errors", errors);
  62. }
  63.  
  64. RequestDispatcher view = request.getRequestDispatcher("main.jsp");
  65. try{
  66. view.forward(request, response);
  67. }catch(ServletException e){
  68. e.printStackTrace();
  69. }
  70. }
  71. }
Can anyone help me with this problem? Thanks before..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xray_slayer is offline Offline
1 posts
since Jul 2008
Aug 7th, 2008
0

Re: URL in address bar,didnt change but the view is correct

i think problem is with jsp...
u might be using frames...thatswhy..
Reputation Points: 10
Solved Threads: 2
Newbie Poster
nikhildoomra is offline Offline
8 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: JSF HTTP 500 error
Next Thread in JSP Forum Timeline: Using Beans in jsp....PLEASE HELP ME STUCK BADLY From 9 days





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC