aspose 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 60048
    
  65

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
 
Similar Threads
make servlet the default "welcome" file for the web app
Ejb 3.0 Unable to run the program in Weblogic or Glassfish server
Servlet Mapping
How to call a servlet doGet or doPost method inside a JSP page on page load
Calling servlet on page load