| | |
error while forwarding page
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jun 2008
Posts: 38
Reputation:
Solved Threads: 0
Hi;
The below page validates the user. if the groupid of the user is null into the database,it forward the user to accessdenied.jsp page. The below code works fine without closing rs
If i had tried to close rs.close(); it show the compile error: rs might not have been initialised.
and without close, it does not work for the accessdenied.jsp
2. Can i access the variable groupid in try.jsp page by request.getparameter() method.
If not then can any have the alternative way for accessing same variable in try.jsp page.
Thanks and Regards
Haresh
The below page validates the user. if the groupid of the user is null into the database,it forward the user to accessdenied.jsp page. The below code works fine without closing rs
If i had tried to close rs.close(); it show the compile error: rs might not have been initialised.
and without close, it does not work for the accessdenied.jsp
JSP Syntax (Toggle Plain Text)
<%-- Document : as Created on : Jul 26, 2008, 12:41:17 PM Author : user1 --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ page language ="java" %> <%@ page import="java.sql.*, javax.sql.*, javax.naming.*,java.io.*,java.util.*" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% String userid=request.getParameter("userid"); String password=request.getParameter("password"); InitialContext context = new InitialContext(); DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/mynewdatabase"); Connection conn = ds.getConnection(); context.close(); Statement stmt=conn.createStatement(); ResultSet rs; try { rs=stmt.executeQuery("select groupid from user where emailid='"+userid+"' and Password='"+password+"'"); %> <% while(rs.next()) { %> <% String groupId = rs.getString("groupid"); out.println(groupId); if ( groupId==null ) { out.println("Invalid User"); %> <jsp:forward page="/AccessDenied.jsp" /> <% } else { out.println("Valid User"); %> <jsp:forward page="/try.jsp" /> <% } } } finally { if (rs != null) { rs.close(); rs = null; } if (stmt != null) { stmt.close(); stmt = null; } } %> </body> </html>
2. Can i access the variable groupid in try.jsp page by request.getparameter() method.
If not then can any have the alternative way for accessing same variable in try.jsp page.
Thanks and Regards
Haresh
It is YOUR school work/work project so deal with it if you ignore advice from others with more experiences!
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;
I am really sorry for ignoring your precious suggestion.
see why I am doing is that i had just completed java course and in class i had learned about how to connect to database in jsp and I am doing that pattern as i had practiced it in lab.
yes, it seems really difficult to modify the jsp code with database connectivity.
now as per your suggestion whether i have to write separate servlet for database connectivity for each jsp page:
Kindly give me few minutes and tell how can use you suggested theme for above jsp page.
in my jsp project there are nearly 35 jsp pages. so for each jsp page should i require to write separate database connectivity servlet.
Give me details
Waiting for your precious suggestion .
Thanks and regards
Haresh
I am really sorry for ignoring your precious suggestion.
see why I am doing is that i had just completed java course and in class i had learned about how to connect to database in jsp and I am doing that pattern as i had practiced it in lab.
yes, it seems really difficult to modify the jsp code with database connectivity.
now as per your suggestion whether i have to write separate servlet for database connectivity for each jsp page:
Kindly give me few minutes and tell how can use you suggested theme for above jsp page.
in my jsp project there are nearly 35 jsp pages. so for each jsp page should i require to write separate database connectivity servlet.
Give me details
Waiting for your precious suggestion .
Thanks and regards
Haresh
If you provide more in detail description of your problem/project then "in my jsp project there are nearly 35 jsp pages" and explain how you got to that conclusion you may actually get some precious suggestions...
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_bodo,
I am developing a project: student feedback system for an institution.
Here each student will get an userid and password .
There are six tables in database to support project
1. User—consist of user information like username, password etc.
2. Groupid—consists of various groups like group of student, group of faculty. Users are divided into various groups.
3. questionid- consists of question of various types. Each question-id consist multiple question
4. Questionbank: consist of large no. of question for particular question-id. Here you can assume question-id=questiontype. Common between above two table is question-id(int).
5. event table—where various event are published. For each event there may be more than one question-id
e.g event—feedback of semester –4-- containing question-id like: question-id for economics batch, question-id for commerce batch
6. Final output table- consist of userid,question-id,question,answer marked by various user.
There are two users. One is normal user and second is system administrator who can add, detete,modify all the questios,user,event, or any module.
So developed the pages for administration add, delete, modify for questionbank, question-id,event,group. So there will be about 15 jsp pages.
Once normal user will log in, it will shows all the event that is marked as published and targeted to the particular group. When it will click on this event it will show the various question-id (consist of various question)available for answering.
The question is in choice format. Like:
1.question name
a.option -A
b.option-B
once user answer all the questions it will stored the final output table.
So I had developed the pages for administrator, also for user to shows various event with question-id, also when user fill all the answer of all question, it will stored in final table.
please dont suggest to change database structure as it is assigned by my boss to me.
I hope it may clear to you.
Thanks and Regard
Haresh
I am developing a project: student feedback system for an institution.
Here each student will get an userid and password .
There are six tables in database to support project
1. User—consist of user information like username, password etc.
2. Groupid—consists of various groups like group of student, group of faculty. Users are divided into various groups.
3. questionid- consists of question of various types. Each question-id consist multiple question
4. Questionbank: consist of large no. of question for particular question-id. Here you can assume question-id=questiontype. Common between above two table is question-id(int).
5. event table—where various event are published. For each event there may be more than one question-id
e.g event—feedback of semester –4-- containing question-id like: question-id for economics batch, question-id for commerce batch
6. Final output table- consist of userid,question-id,question,answer marked by various user.
There are two users. One is normal user and second is system administrator who can add, detete,modify all the questios,user,event, or any module.
So developed the pages for administration add, delete, modify for questionbank, question-id,event,group. So there will be about 15 jsp pages.
Once normal user will log in, it will shows all the event that is marked as published and targeted to the particular group. When it will click on this event it will show the various question-id (consist of various question)available for answering.
The question is in choice format. Like:
1.question name
a.option -A
b.option-B
once user answer all the questions it will stored the final output table.
So I had developed the pages for administrator, also for user to shows various event with question-id, also when user fill all the answer of all question, it will stored in final table.
please dont suggest to change database structure as it is assigned by my boss to me.
I hope it may clear to you.
Thanks and Regard
Haresh
What are the major views that admin and student get?
Like admin will see some of these options
Like admin will see some of these options
- add
- delete
- modify
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,
Once student log in he/she will see the link of all event available in table event and marked to that particular group. Once it will click on the that link it will shows the related question-id (question-title) name from question-id table. Once user click on that link it will see all the question belong to the question-id in questionbank table .
Answer of question is in radio-button format for choice a, choice-b which also from option available in questionbank table for respective question . once he/she will mark all question the result will stored in final table.
So view will contain first page- event name from event table click->> retated question-id(question-title) from question-id table click all questions and related options from questionbank table.
Thanks and Regards
Haresh
Once student log in he/she will see the link of all event available in table event and marked to that particular group. Once it will click on the that link it will shows the related question-id (question-title) name from question-id table. Once user click on that link it will see all the question belong to the question-id in questionbank table .
Answer of question is in radio-button format for choice a, choice-b which also from option available in questionbank table for respective question . once he/she will mark all question the result will stored in final table.
So view will contain first page- event name from event table click->> retated question-id(question-title) from question-id table click all questions and related options from questionbank table.
Thanks and Regards
Haresh
Can you get me full table descriptions with indication of primary keys? (Just table structure, not interested in data inside table)
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;
here is my table structure of database:
I had just copied the database creation page.
Thanks and Regards
Harshal
here is my table structure of database:
JSP Syntax (Toggle Plain Text)
CREATE TABLE user ( userid int(4) NOT NULL auto_increment, firstname varchar(100) NOT NULL, lastname varchar(100) NOT NULL, emailid varchar(100) NOT NULL UNIQUE, password varchar(50) NOT NULL, groupid int(8) not null, PRIMARY KEY ( userid) ); CREATE TABLE markedevent ( userid int(4) NOT NULL , eventid int(4) NOT NULL, PRIMARY KEY ( userid) ); CREATE TABLE Event ( Eventid int(4) NOT NULL AUTO_INCREMENT, Description varchar (255) NOT NULL, Publish varchar(20) NOT NULL, Questionid int(4) NOT NULL, Targetgroup varchar(70) NOT NULL, Anonymous varchar(15) NOT NULL, PRIMARY KEY ( Eventid ) ); CREATE TABLE Questionid ( Questionid int(4) NOT NULL AUTO_INCREMENT, Description varchar(70) NOT NULL, Type varchar(70) NOT NULL, PRIMARY KEY (Questionid) ); CREATE TABLE QuestionBank ( Qserialno int(3) NOT NULL AUTO_INCREMENT, Questionid int(4) NOT NULL , Questionname varchar(255) NOT NULL, OptionA varchar(50), OptionB varchar(50), OptionC varchar(50), OptionD varchar(50), Other varchar(50), Answer varchar(1), PRIMARY KEY (Qserialno, Questionid ) ); CREATE TABLE Final ( Userid int(4) , Eventid int(4) NOT NULL, Questionid int(4) NOT NULL, Qserialno int(3) NOT NULL, Answer varchar(8) NOT NULL );
Thanks and Regards
Harshal
![]() |
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 backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






