This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data from database on the index page

 
Marek Krokosinski
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make the welcome page the servlet, not the JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic