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?
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!!!
All desirable things in life are either illegal, banned, expensive or married to someone else !!!
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" />
Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Joined: Nov 10, 2003
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?
Joined: Oct 04, 2003
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
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 ]
Java training and consulting<br /><a href="http://www.coreservlets.com/" target="_blank" rel="nofollow">http://www.coreservlets.com/</a>