This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

writing web.xml

 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well... okay.
Anyway your web.xml looks ok unless you happen to package your servlets.
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a servlet mapping in your request URL? Something like
http://{hostname}:{port}/{context}/{url-mapping}
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
somebody plz help.. :roll:
malhar
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry... I was out.
You have to find out the HTTP port.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
----------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic