Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

make servlet the default "welcome" file for the web app

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am creating an application in which I would want my first page(viewable to the user) to have a list that was generated using a DB call.
Currently, since I am using MVC architechture, so this logic( DB call ) is hidden in a servlet called, "welcome.java". Since the logic should be hidden, I am implementing a redundant step. In my index.jsp, which is my current default "<welcome file>", all I have is
<jsp:forward page="./welcome.java"></jsp:forward>
Welcome.java makes the DB call and stores the info in a vector which is set as an attribute to the request object. After this, welcome.jave forwards to a jsp "home.jsp", which accesses the request attribute and builds up a list.
My question is : Is there a way of bypassing the index.jsp route? All that this page does is forward to welcome.java. If somehow I could make my webcontainer call "welcome.java" when the users run the app, then I could do away with "index.jsp". Is there a way to make a servlet a "<welcome file>" ( as in web.xml ) of the application?
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trunali,
One confusion....
what do u mean by welcome.java in
<jsp:forward page="./welcome.java"></jsp:forward>?
well now coming back to your problem,I cudnt make taht work.
But i manage to do same thing with html,dont know wether it has any impact on perfomance still .....
just add this line in inde.html

AND KINLDY LET US KNOW IF U CAN MAKE IT WORK WITHOUT ANY INTERMIDATE FILE!!!
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please look at using web.xml within your context /WEB-INF directory to create a servlet mapping. If you create a mapping from / to your servlet then when they open that folder it will show your servlet.
unless you have a very strange setup then
<jsp:forward page="./welcome.java"></jsp:forward>
shouldnt work. I'm presuming your doign something like page="servlet/blah"
also note you dont need the </jsp:forward> if you close the first tag in itself like this:
<jsp:forward page="servlet/blah" />
 
Trunali Grissom
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your comments.
Praful, the welcome.java is a servlet and forwarding to a servlet should work. It is working for my application. I dont need to use the html format as it works using the jsp tags.
Tim,
I looked at your comments. I think I am not clear about what you are saying. Are you saying that by somehow mapping the servlet "welcome.java" and set it's url pattern to "/context root/welcome.java " will make it the default to the web application?
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what i'm saying is edit your web.xml to have this in it:

if you don't know what web.xml is you need to go read some servlet tutorials / introductions
 
Author
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A couple of quick comments:
  • I assume you don't really mean "welcome.java" in your jsp:forward call, but instead mean "registered-URL-of-the-Welcome-servlet".
  • No, you can not use the address of a servlet in the web.xml welcome-file-list element, at least not until JSP 2.0. That entry specifies physical files in the directory, not general URL patterns (that is why it is called welcome-file-list instead of welcome-pattern-list or some such, BTW).
  • However, the servlet-mapping element lets you specify arbitrary URL patterns that should be answered by servlets, so you can easily use this to skip the index.jsp step.
  • Very minor detail, but you can do <jsp:forward page="blah"/> instead of <jsp:forward page="blah"></jsp:forward>, if you want.


  • Cheers-
    - Marty
    [ November 11, 2003: Message edited by: Marty Hall ]
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic