This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Data from database on the index page" Watch "Data from database on the index page" New topic
Author

Data from database on the index page

Marek Krokosinski
Ranch Hand

Joined: Jun 10, 2011
Posts: 64
Hello.

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 www.example.com or www.example.com/index.jsp . 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 www.example.com, 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 "MyServlet.do" 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

MK
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61457
    
  67

Make the welcome page the servlet, not the JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data from database on the index page