error while forwarding page

Thread Solved

Join Date: Dec 2004
Posts: 4,197
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: error while forwarding page

 
-1
  #21
Aug 4th, 2008
I finally had look on what you done so far. Many of the JSP pages with DB connectivity can be combine into one servlet and that will reduce size of the whole project. For example login process with retrieving user info you do (assuming we have correct username and password)

index.jsp=>as.jsp(to check username&password)=>try.jsp(to retrieve user group data and display events)=>Questionforvote/fillquestion.jsp

simplified version should be
  1. index.jsp
  2. loginServlet.class
    • setup db connection
    • check if user exist
      1. user doesn't exist
        • set error message
        • set session attributes
        • return back to index.jsp that will display error message from session
      2. user does exist
        • get events available for user
        • store events in the session
        • redirect to next page
  3. events.jsp

Any questions?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 38
Reputation: guravharsha is an unknown quantity at this point 
Solved Threads: 0
guravharsha guravharsha is offline Offline
Light Poster

Re: error while forwarding page

 
0
  #22
Aug 5th, 2008
Hi peter_budo,
Thank you very much for your cooperation.
I have some doubt like in loginServlet.class
Whether I have to connect database for table user and event and retrieving the neccessary field and store in session attributes?
index.jsp
loginServlet.class
setup db connection
check if user exist
user doesn't exist
set error message
set session attributes
return back to index.jsp that will display error message from session
user does exist
get events available for user
store events in the session
redirect to next page
I could not understand about: set session attributes
THis is for normal user.
Now if the user is administrative then it has to add,modyfy and delete the user,group,question,event like.
So I required seprate connection for that?
Can you give me some demo of my updated code view.for above mentioned page.
just give me atlest loginservlet logic.
Thanks and Regards
Haresh
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,197
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: error while forwarding page

 
-1
  #23
Aug 5th, 2008
How you gone distinguish between users groups that is what I asked you to answer in Database design section when I provided few suggestions. Unfortunately so far I did not get answer to that...

Check second post of this thread there is already partial implementation. After validation of submitted data, connect to database to retrieve info on user. The query will either return user details if username and passwords are correct or NULL if one of them fail. If null close DB connection and jump to redirect and go back to login screen. However if query return user details do not close connection but run another query this time on events related to userID and groupID. Exact queries are up to you.
Passing user details from servlet to JSP in session is very simple something like this
  1. // what is structure of User bean doesn't matter in this example
  2. // data retrived from the database and stored in a instance of User bean "user"
  3. HttpSession session = request.getSession();
  4. if(BOOLEAN_DATA_SUCCESSFULLY_RETRIEVED)
  5. {
  6. session.setAttribute( "user", user);
  7. RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/event_page.jsp");
  8. dispatcher.forward( request, response);
  9. }
  10. else
  11. {
  12. String strError = "Wrong username or password!";
  13. session.setAttribute( "error", strError);
  14. RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp");
  15. dispatcher.forward( request, response);
  16. }
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 38
Reputation: guravharsha is an unknown quantity at this point 
Solved Threads: 0
guravharsha guravharsha is offline Offline
Light Poster

Re: error while forwarding page

 
0
  #24
Aug 8th, 2008
Hi Peter_buto,
I want to really appreciates for your help.
Now i am going to Forward with you suggested project Structure. If i require any Help ,
I will come here again and call to you for help. As i completed 70% of my project work with older fashion,it will take some time to modulate into new form.
Thanks again
Regards
Haresh
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,197
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: error while forwarding page

 
-1
  #25
Aug 8th, 2008
That is OK.
Are you gone do anything with database structure? It is very inefficient...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
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