aspose file tools*
The moose likes Struts and the fly likes get data from database when jsp page load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "get data from database when jsp page load" Watch "get data from database when jsp page load" New topic
Author

get data from database when jsp page load

Alan Jeri
Greenhorn

Joined: Jun 05, 2008
Posts: 4
I want to known how to get data from database when the jsp page first load on the WebServer,but I don't want to user JSTL tag
Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
you can use the scriptlet tags i.e.
<% 'your Java Database connection and data fetching stuff here' %>


SCJP 1.5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

If you follow modern web application best practices, this is the type of thing you'd do in the page controller servlet before the JSP is invoked.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alan Jeri
Greenhorn

Joined: Jun 05, 2008
Posts: 4
I have start my project with struts2 + spring + hibernate ,
I don't want to use scriptlet ,because I think it is hard to vindicate.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Yes, avoid scriptlets.

If you are using Struts, the pages prep action is the perfect place to delegate this type of activity.
Alan Jeri
Greenhorn

Joined: Jun 05, 2008
Posts: 4
but I don't know how to go to the action when the jsp page first load,This is my problem
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

You go to the action first.

Since this has become about Struts, I've moved it to the Struts forum.
Alan Jeri
Greenhorn

Joined: Jun 05, 2008
Posts: 4
but Do it like this, look not very good ,thank you all the same!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get data from database when jsp page load
 
Similar Threads
Iterate a Arraylist on onclick event.
Loading once with values onload
How to create a drop down on pageload with data from a db
how to refresh the jsp page when onload?
request.getAttribute from servlet on jsp page load