aspose file tools*
The moose likes Servlets and the fly likes writing web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "writing web.xml" Watch "writing web.xml" New topic
Author

writing web.xml

Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
hi all
actually my server guy has deleted web.xml by mistake & now i not able to run servlets.
can someone help me in writing a web.xml to even run a simple HelloWorld application.
i wrote web.xml as follows, plz specify any modifications to be done :
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>
HelloWorld
</servlet-name>
<servlet-class>
HelloWorld
</servlet-class>
</servlet>

</web-app>
tia
malhar
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
If you are using tomcat4, you can also go to {tomcat_install_dir}\conf and copy the web.xml file there. Copy it to your webapps's WEB-INF folder and edit this web.xml to your preferences.
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
If you are using tomcat4, you can also go to {tomcat_install_dir}\conf and copy the web.xml file there. Copy it to your webapps's WEB-INF folder and edit this web.xml to your preferences.

dear
actually i dont hv access to any other folders, so cant copy frm there & basically the server is maintained by a fool...he doesnt know any thing abt configurations & all my requests wud be remain unattended. so basically i'll hv to rewrite the file...
thnx anyway
malhar
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Well... okay.
Anyway your web.xml looks ok unless you happen to package your servlets.
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Anyway your web.xml looks ok unless you happen to package your servlets.

well...
i m not using package but still its giving 404 error..
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Are you using a servlet mapping in your request URL? Something like
http://{hostname}:{port}/{context}/{url-mapping}
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Originally posted by Anthony Villanueva:
Are you using a servlet mapping in your request URL? Something like
http://{hostname}:{port}/{context}/{url-mapping}

no dear
i m just using
http://<hostname>/servlet/<servletclassfile>
ta...still
malhar
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
somebody plz help.. :roll:
malhar
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Sorry... I was out.
You have to find out the HTTP port.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Did you restart the server?
and did you put the web.xml in 'webapps/ROOT/WEB-INF/'?
Rene
[ July 30, 2002: Message edited by: Rene Larsen ]

Regards, Rene Larsen
Dropbox Invite
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Did you restart the server?
and did you put the web.xml in
'webapps/ROOT/WEB-INF/'?
Rene

dear rene
i only hv access to web-inf folder, cant know if its under web-apps/ROOT...
i m still looking at anthony's solution & trying to get the port, but if the port is 80 i think we wud be better off writing as
http://<hostname>/... instead of
http://<hostname>:80/...
thnx anyway
malhar
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Rene is right. You have to find out somehow if the web.xml is in the right directory. Also you must restart Tomcat for your new web.xml to take effect.
sandeep balyan
Ranch Hand

Joined: Jul 25, 2001
Posts: 134
Hi have a look
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"web-app_2_3.dtd">
<web-app>
<display-name>urchoice</display-name>
<description>
any message description
</description>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<description>
abt servlet
</description>
<servlet-class>myservlet.servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
regds
----------
if any problem chk the version of
web-app_2_3.dtd
and use according
----------------


Want to do something great will do one day
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: writing web.xml