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

Reply

Join Date: Jul 2008
Posts: 1
Reputation: xray_slayer is an unknown quantity at this point 
Solved Threads: 0
xray_slayer xray_slayer is offline Offline
Newbie Poster

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

 
0
  #1
Jul 22nd, 2008
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:
  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..
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: nikhildoomra is an unknown quantity at this point 
Solved Threads: 2
nikhildoomra nikhildoomra is offline Offline
Newbie Poster

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

 
0
  #2
Aug 7th, 2008
i think problem is with jsp...
u might be using frames...thatswhy..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC