• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

jsp resultset

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i enter to jsp and call servlet in java session and then return a resultset
afterwards, i get the value of resultset and then pass to session
the code as below

in jsp:
<%
xx a=new object();
ResultSet rs=a.select_user();
String strID=rs.getString("ID");
session.setAttribute("ID",strID);
%>

when i compile the code, there is an error about "record before resultset" somthing like that

how can i fix this???

because i would like to get the value from another jsp by getting session.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you import java.sql.ResultSet in jsp page?
you can talk to me with msn if you need
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the ranch !

there is an error about "record before resultset" somthing like that


No, you'll have to be more specific. "something like that" is not going to help us. Please send the exact error that you have.

And also check your private messages.
 
Aaron Liu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can attach a screenprint jpg file to this topic for more details.
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
session.setAttribute("ID",rs.getString("ID"));

javax.servlet.ServletException: java.sql.SQLException: Before start of result set
 
Aaron Liu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
before you "result.getXXX", you should call result.next().
see below:
<%
xx a=new object();
ResultSet rs=a.select_user();
if(rs.next()){
String strID=rs.getString("ID");
out.println("strID = " + strId);
session.setAttribute("ID",strID);
}else{
out.println("there is no data in resultset");
}
%>
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i get exactly the data of row in the resultset, not everytime is "while(rs.next())"
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic