aspose file tools*
The moose likes Tomcat and the fly likes Web.xml problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Web.xml problems" Watch "Web.xml problems" New topic
Author

Web.xml problems

Raghu Sudhakara
Greenhorn

Joined: Aug 04, 2003
Posts: 5
I am basically trying to run servlets on jakarta-tomcat 3.3.1 with IIS as the webserver on a Win 2000 machine. (This combination due to client requirements). I previously ran servlets on Apache and Jserv with no problems. I had a properties file with init args in my original jserv.
My first question is : Do I need to add those init args to the web.xml file in the web-inf directory.
Secondly I did add a param name and value (in the commented init param section) in the default web.xml that came with tomcat. I then tried to uncomment the section and it gives me an error. Can anyone help me with the method to uncomment stuff in web.xml.
Thirdly, is there any other way to integrate a my.properties files into jakarta tomcat without messing with the xml file.
Any help will be greatly appreciated. I am really frustrated and stuck at this juncture and my non-software background isn't helping either.
Thanks..
Just wanted to add that I could uncomment stuff in web.xml but my param value has & and probably that was causing the error. My main question now is how to integrate a *.properties file into jakarta-tomcat (the prev loc of the *.properties file being added in the conf file of the Apache jserv directory)
[ August 05, 2003: Message edited by: Raghu Sudhakara ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
1. If you want init params to be available in the servlet init method, yes
2. It is extremely likely you ended up with either bad XML or elements out of order. For the requirements of web.xml, download the servlet API from java.sun.com - its a big PDF file with LOTS of examples.
3. You can put the properties file in the WEB-INF directory and read it.
Bill


Java Resources at www.wbrogden.com
Raghu Sudhakara
Greenhorn

Joined: Aug 04, 2003
Posts: 5
Originally posted by William Brogden:
1. If you want init params to be available in the servlet init method, yes
2. It is extremely likely you ended up with either bad XML or elements out of order. For the requirements of web.xml, download the servlet API from java.sun.com - its a big PDF file with LOTS of examples.
3. You can put the properties file in the WEB-INF directory and read it.
Bill

Bill thank you so much. How do you have tomcat directory read the properties file after putting it in the WEB-INF directory. The original error I got in my browser was: Error data_url=[url] must be specified in the initial parameters, in the URL query string, or in the FORM post data
my data_url is a long string containing '&' characters. Details about all the initial parameters are in a file called my.properties. I basically want tomcat to know to look into this file for all initial params. Can we do this putting the properties file in WEB-INF?
Thanks in advance
Raghu Sudhakara
Greenhorn

Joined: Aug 04, 2003
Posts: 5
I have added additional details in this message so that exactly what i want to do is clear... Help really really needed here.... Thanks in advance
I am trying to run servlets on IIS using tomcat as the servlet engine. Previously I ran the servlets on Apache webserver with jserv without any problems. I am totally new to this area...
In apache I had a application.properties file that I loaded by including it in the jserv config file with the statements:
zones = root, application
application.properties=MY_DIR\servlets\application.properties
I am now looking for parallels in tomcat. Would you by any chance know how I can do this without going into the actual servlets and doing any changes. I would appreciate any help in this regard. The properties file in my case contains init arguments for two different servlets and I want this file avaliable to tomcat all the time.
Thanks,
Raghu
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
I have read properties files two ways:
1. Put the absolute path and file name in web.xml as an init parameter - that way you can put the file anywhere you like but the location is not portable.
2. Use the servlet context method getResourceAsStream to open a file relative to the application home directory. Example:

That way the location is portable.
Bill
Raghu Sudhakara
Greenhorn

Joined: Aug 04, 2003
Posts: 5

That way the location is portable.
Bill[/qb]<hr></blockquote>
Thanks so much Bill. I have one final question. I tried the first solution since I am not concerned much with portability. This is for internal use by a few people at my firm.
When I add C:/jakarta-tomcat/webapps/myapp/WEB-INF/fusion.properties, I get an error of malformed c in my browser. When I use the traditional /WEB-INF/fusion.properties or myapp/WEB-INF/fusion.properties as my param value, I get a error 403 for URL: http://localhost:8080/WEB-INF/fusion.properties What kind of addressing do I need to use to refer to the file?
Thanks in advance,
Raghu
[ August 06, 2003: Message edited by: Raghu Sudhakara ]
[ August 06, 2003: Message edited by: Raghu Sudhakara ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web.xml problems
 
Similar Threads
How can make .war file for IBM websphere configurable?
setting jsp compiler
Problems getting servlets to work on Tomcat 4
Problems getting servlets to work on Tomcat 4
Struts Problem in the March Article