• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error showing while retrieving the data from drop down list

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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?
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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 ]
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic