File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Data from database on the index page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Data from database on the index page" Watch "Data from database on the index page" New topic

Data from database on the index page

Marek Krokosinski
Ranch Hand

Joined: Jun 10, 2011
Posts: 64

I'm wondering how to put data on the index page. I'm using hibernate. Servlet should take data from database and dispatch it to the index.jsp with request.
If I would have a static index page (without any data from database) user would type or . Index. jsp is in DD in welcome-file-list and everything should work fine right? If I want to have a dynamic data in my index.jsp I have to call servlet first, but when user makes request for, he makes request for index.jsp, servlet is not called so it won't get and dispatch data to the index.jsp.
I have one solution for this problem, but I'm not sure is it correct. Do I have to put "" in my welcome-file-list instead of index.jsp ? I think there must be other solution. I saw many jsp/servlet based sites which have dynamic data in theirs index.jsp. Of course they could map the servlet as "index.jsp" but I don't belive in this really.

best regards

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63846

Make the welcome page the servlet, not the JSP.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Data from database on the index page
jQuery in Action, 3rd edition