| | |
error while forwarding page
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
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
Any questions?
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
- 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
- user doesn't exist
- 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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Jun 2008
Posts: 38
Reputation:
Solved Threads: 0
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?
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
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
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
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
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)
// what is structure of User bean doesn't matter in this example // data retrived from the database and stored in a instance of User bean "user" HttpSession session = request.getSession(); if(BOOLEAN_DATA_SUCCESSFULLY_RETRIEVED) { session.setAttribute( "user", user); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/event_page.jsp"); dispatcher.forward( request, response); } else { String strError = "Wrong username or password!"; session.setAttribute( "error", strError); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp"); dispatcher.forward( request, response); }
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Jun 2008
Posts: 38
Reputation:
Solved Threads: 0
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
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
That is OK.
Are you gone do anything with database structure? It is very inefficient...
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Optimum Online Web Hosting. (Networking Hardware Configuration)
- "How Much Would 'You' Charge?" (Website Reviews)
- SYSVER 0xff00024 NT_Kernel error (Viruses, Spyware and other Nasties)
- Netgear router blocking Hotmail (again) (Networking Hardware Configuration)
- MarbleHost.com: Safe web host providing daily data backup (Web Hosting Deals)
- Cpanel Hosting, 14gb disk space, 350gb traffic free domain this month only $19.90 (Web Hosting Deals)
- JSP iterator error with structs (JSP)
- delay forwarding of page (PHP)
- 5GB Diskspace/100GB Bandwidth -$5.95 Per Month. First Month (Web Hosting Deals)
- 15GB Diskspace .:. 100GB Bandwidth - I'll Try That For A $1.00 (Web Hosting Deals)
Other Threads in the JSP Forum
- Previous Thread: general questions about jsp
- Next Thread: Open Office document in IE browser
| Thread Tools | Search this Thread |
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






