aspose file tools*
The moose likes JDBC and the fly likes error showing while retrieving the data from drop down list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "error showing while retrieving the data from drop down list" Watch "error showing while retrieving the data from drop down list" New topic
Author

error showing while retrieving the data from drop down list

Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi,
In the below jsp page, i am retrieving the data from drop down list of adduser.jsp page .but showing the error like:
javax.servlet.ServletException: java.sql.SQLException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
The error showing is at marked line.
Here is an code:

Thanks
Harshal
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Here try this code instead of yours.. The code that you highlighted seems to be not good..You must use rs.next() inorder to fetch values from DB...But where you do it?...Please do read more about JDBC and correct way to use it...


Also read the article in this -LINK- . It may be very helpful to you Harshal...
[ July 11, 2008: Message edited by: Rajkumar balakrishnan ]

Never try to be a hard-worker. Be a smart-worker.
My Blog
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121


This marked line reads from the ResultSet before you call rs.next() and hence results in an Exception. Even to read the first fetched record, you have to call rs.next() to move the cursor to the first record.

By the way, I see that you call rs.getString("userid") and rs.getString("EMAIL") later in the code, but where are you fetching them?


keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi
but i am using drop down list name(form1) as reference from the previous jsp page(searchuser.jsp) to retrive data from table i.e suppose i selected abc user as option in drop down list in searchuser.jsp page, i am expecting to get data related to that abc user in table in updateuser.jsp page .And accordingly i marked quary as:
now my page displaying the result as jsp
tag %>
Any suggestion is highly appreciated.
Thanks and Regards
Harshal
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Will you put your modified code here.So we can answer effectively..If you still not modify the code it's hard to give you the answer..
Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi Rajkumar,
Thanks very much for your helping attitude.I want hertly appreciate your suggestion.
Now I am enclosing both jsp pages i.e 1. searchuser.jsp where moderator can select name of particular employee from drop down list and after submitting this page, in the next page i.e updateuser.jsp i will get all the details of employee like here email and password. My next aim is updating all detail of employee I can feed the updated date into the table:
Here is searchuser.jsp:

And here is an updateuser.jsp:

Kindly Suggest me Required modification.
Thanks and Regards
Harshal
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445



The way you print is wrong..You already fetch the data from DB and store it in variable name EMAIL and PASSWORD..so you must print them in the Table or whatever else.
So change your code like this..
<input type=text value="<%=EMAIL%>">

and for password just replace EMAIL with password in the above code... Hope this might help you.. You need to learn more about JDBC that's what i suggest you from your earlier post itself..
[ July 11, 2008: Message edited by: Rajkumar balakrishnan ]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Harsha,

By looking at your recent posts (which are almost similar in the forums), you can better take some time off to study the JDBC concepts and tutorial. It will really help you and facilitate you to proceed further without any hassles.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi Raghavan,
As You suggested code cause my jsp page is running dut showing output as
jsp syntax as %>
How can display this data in table form. I think my code inside the table is not working.
Kindly update me.
Thanks
Regards
Harshal
[ July 11, 2008: Message edited by: Harshal Gurav ]
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Wouldn't you try the code that i post here...? Please do read some tutorials and please check your JSP file line by line which may helpful to you in time..
Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151
Hi Rajkumar,Raghavan
Thanks for your Suggestion.
I am Definately follow The Instruction as you suggest me.
I want to just know whether it is possible to display the data in updateuser.jsp page I tabular format which is related to the option selected in searchuser.jsp page.
Regards
Harshal
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Yes it's possible..You can display it in whatever format you want.. Your code seems to be ok and with the code and instructions that we gave itself will solve your problem. You still experience any problem with your code...huh...Then let us know about it clearly..
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Harshal Gurav:
showing output as
jsp syntax as %>


Just check the JSP syntax for proper matching/nesting of directives (<%.. %>) in your .jsp file!


How can display this data in table form. I think my code inside the table is not working.

You can display them using <table> tag and you have to iterate the data by using <tr><td> repeatedly as follows.

<blockquote>code:
<pre name="code" class="core">
//Say for example, you have a java.util.List which has the data to be displayed and you get it from session

<%
List myList = (List) session.getAttribute("EmployeeList");

//now you need to iterate the list..

Iterator iterator = myList.iterator();

%>
<!--Here is the HTML comment as the Java comment will not work here. All java related code are put inside the scriptlets which are the piece of code enclosed within <% .. %> tags! -->

<table>

<!-- Have as many headers you would want to display and matching values are there in the list -->

<th>Name</th>
<th>Age</th>
<th>Department</th>

<!-- Now you need to display the *actual* values from the list into each row and column -->

<%
while(iterator.hasNext())
{
Employee emp = (Employee) iterator.next();
%>
<tr>
<td><%= emp.getName()%></td>
<td><%= emp.getAge()%></td>
<td><%= emp.getDepartment()%></td>
</tr>
<%
}
%>
</table>
</pre>
</blockquote>

Hope this sample code would help! If you don't understand what exactly this means, kindly take some time to read about JSP basics and especially scriptlets. It would help you to proceed further!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: error showing while retrieving the data from drop down list