File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help With Accessing Multiple Access Database Tables Using JSP

 
Nishant Vashisth
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys i need to feed in data from multiple tables on a jsp page..
please help me !!
i know how to do it using one table by using the use bean property and then using the snipplet but i don't know how to do it using multiple tables !!
 
Rinkit Shah
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open database connection once and then try using ResultSet(rs),Statement(stmt)
rs.stmt.executequery("Query");
or rs.stmt.executeUpdate("Query")
and while you want to retrieve from that table use while(rs.next)
and finally close database connection
I hope this works !!!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not be doing any database access, or even have any Java code at all, in a modern JSP. Do this type of thing in a Java class where it belongs.

In any case, this is not a JSP questions so it's been moved to the JDBC forum.
 
Nishant Vashisth
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if its so then how to use data base in a jsp page ??
it not like we can work around without database !!!

please share any other modern way if you have i'd be obliged to learn it !!
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "modern" way -- which has been the professional way for about eight years now -- is to collect and prepare the data in a servlet, or some other similar component, before forwarding the collected data to a JSP to be made into HTML.

Doing it that way allows you to use ordinary Java/JDBC code to access the database, so you don't have to concern yourself about "how to access the database from a JSP".

As for accessing multiple tables, you might want to use an SQL join or something like that. But the question is far too lacking in detail for anybody to provide a useful answer.
 
Rinkit Shah
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As it is said that it is not a "good practice" to open connection in a jsp page can anyone please help us how to get data into jsp from Servlet.

I am able to save data from jsp to database wih help of data helper class and servlet by help of request.getparameter attribute and setting beans. But I am unable to find a solution of how to display data from servlet to jsp or html file can anyone help in this.
 
Glisic Slavko
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rinkit Shah wrote:As it is said that it is not a "good practice" to open connection in a jsp page can anyone please help us how to get data into jsp from Servlet.

I am able to save data from jsp to database wih help of data helper class and servlet by help of request.getparameter attribute and setting beans. But I am unable to find a solution of how to display data from servlet to jsp or html file can anyone help in this.


Well I'm not sure what is your app architecture, and how do you handle request/response, but just to answer your question(even there are many mvc framework out there that is preferred to use it):


And in request or session object you can store whatever you want.

Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article.
 
Nishant Vashisth
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys you are miss understanding me !!

i am not making connections on a jsp page i am well aware of the way !!

i am making a connection on a java class and forwarding the resultset to the jsp page !!

what i wanted to ask was that i can use data of one table easily but using multiple tables is creating problems !!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33700
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nishant,
They are not misunderstanding. The problem is still that you are trying to use the JDBC ResultSet on the JSP page. This is causing problems because you want multiple resultsets open at the same time. (and you probably also have a connection link from not closing the connection probably.)

With MVC architecture, you read from the database/resultset storing the result in Java objects completely disconnected from the database. You place those in request.setAttribute() and the JSP reads those beans without any database interaction at all.
 
Nishant Vashisth
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay !!
getting your point to some extent !!
can you send me a link to a tutorial for this ??
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic