permaculture playing cards*
The moose likes Servlets and the fly likes welcome file in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "welcome file in web.xml" Watch "welcome file in web.xml" New topic
Author

welcome file in web.xml

ankur trapasiya
Ranch Hand

Joined: Sep 24, 2010
Posts: 160



Here i have only one servlet in my project and i want to set it as home page. Is is possible ?? I tried all the options in <welcome-file> tag. It simply not working...

please help...


OCPJP(83%)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

ItDoesntWorkIsUseless

What is happening?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

And, sigh, what's with the .do? It's completely unnecessary and extraneous.
Ivan Pig
Greenhorn

Joined: Jun 28, 2009
Posts: 2
It should work,but when it works,it'll go to /Index.do,then invoke the servlet basics.Index.....
You can change the /Index.to to any normal page...
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

@OP
Remove the .do and try use the jsp/html page. I dont know what a .do is doing there.
If you want to redirect it to your servlet, then write a page redirect in index.html and use that as welcome file. Simple!


Never try to be a hard-worker. Be a smart-worker.
My Blog
Malatesh Karabisti
Ranch Hand

Joined: Jul 28, 2010
Posts: 153

In welcome file list you can have any thing either static html or Jsp/Servlet. Post exactly what is happening. Is your complete servelt path url is working fine ?
ankur trapasiya
Ranch Hand

Joined: Sep 24, 2010
Posts: 160

It works if i use full path ... e.g. http://localhost:8080/ServletsBasics/Index/
but i want it as my welcome page.... by default the page that is opened is http://localhost:8080/ServletsBasics/

And i am not using any HTML or JSP pages. I just want to know if it is possible to make servlet as a start page ot not....

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Yes, it is, as of Servlets 2.4.
ankur trapasiya
Ranch Hand

Joined: Sep 24, 2010
Posts: 160

Then what changes do i have to made in web.xml ??

i tried

1) <welcome-file>/Index</welcome-file>
</welcome-file-list>

2) <welcome-file>basics.Index</welcome-file>
</welcome-file-list>

Both of this settings are not changing my homepage to Index servlet...
ankur trapasiya
Ranch Hand

Joined: Sep 24, 2010
Posts: 160

ankur trapasiya wrote:Then what changes do i have to made in web.xml ??

i tried

1) <welcome-file>/Index</welcome-file>
</welcome-file-list>

2) <welcome-file>basics.Index</welcome-file>
</welcome-file-list>

Both of this settings are not changing my homepage to Index servlet...


tried third one
<welcome-file>Index</welcome-file>
</welcome-file-list>

it works perfectly...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: welcome file in web.xml