943,915 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 3073
  • JSP RSS
You are currently viewing page 3 of this multi-page discussion thread; Jump to the first page
Aug 4th, 2008
-1

Re: error while forwarding page

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?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Aug 5th, 2008
0

Re: error while forwarding page

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?
Quote ...
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
Reputation Points: 8
Solved Threads: 0
Light Poster
guravharsha is offline Offline
42 posts
since Jun 2008
Aug 5th, 2008
-1

Re: error while forwarding page

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
java Syntax (Toggle Plain Text)
  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. }
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Aug 8th, 2008
0

Re: error while forwarding page

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
Reputation Points: 8
Solved Threads: 0
Light Poster
guravharsha is offline Offline
42 posts
since Jun 2008
Aug 8th, 2008
-1

Re: error while forwarding page

That is OK.
Are you gone do anything with database structure? It is very inefficient...
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: general questions about jsp
Next Thread in JSP Forum Timeline: Open Office document in IE browser





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


Follow us on Twitter


© 2011 DaniWeb® LLC