The moose likes IDEs, Version Control and other tools 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "welcome file in web.xml" Watch "welcome file in web.xml" New topic

welcome file in web.xml

thejwal pavithran
Ranch Hand

Joined: Feb 11, 2012
Posts: 119
Hi guys servlet beginner needs help..

I am having doubts in how to configure the web.xml file in eclipse juno.
What i am trying to do is create a servlet that takes in a users name through an html file and print the message "welcome" followed by name.

Now I have created a servlet that takes the input from the html file through getParameter and displays the correct output..i run it by right clicking on the html file and then clicking on the run on server option.
The html file i have named as welcome.html.

in web.xml , the url pattern is /TestApp and the welcome-file i have set to welcome.html so i am expecting when i right click on servlet and use run on server the welcome.html to be displayed first..but welcome null is displayed..which means that the servlet takes control directly please help..

So what i am expecting to happen when i right click on the servlet is to take me to the html file which asks the user for input but instead i am taken to the TestApp directly and it displays Welcome null..

the servlet is as below :

on job hunt
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

Right click on the project and run on server...don't select any spcific resource (servlet, JSP etc) in your web app.

Welcome file will be detected and executed.

Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 662

Right click on your project and select run on server. You should see welcome.html, in case you have configured welcome-file-list properly in web.xml.

When you right click on servlet and choose run on server, how do you expect it to present you welcome.html? How come the servlet will know, from where it will get the request? It just invokes the servlet directly..
thejwal pavithran
Ranch Hand

Joined: Feb 11, 2012
Posts: 119
Thank you guys I think i saw somebody right click on the servlet source code and get the welcome.html file..that was what i was trying to do till now..thanks for your help..
I agree. Here's the link:
subject: welcome file in web.xml
jQuery in Action, 3rd edition