File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 60999
    
  65

Make the welcome page the servlet, not the JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: Data from database on the index page