Hi, i have created a html form named form1.html and stored it in /opt/tomcat/webapps/project ie the path now is: /opt/tomcat/webapps/project/form1.html in eclipse, i have created a new tomcat project "Formpro". inside this project is a package "formpack". now in formpack, i create a new servlet "formservlet.java" that contains the servlet that takes the input from form1.html and displays the output (ie the input data entered with a greeting) now in "Formpro" i created a web.xml file like this:
now i go to my Mozilla browser, open my form1.html program and give the input, but the error message i get is: the file /hello cannot be found. Please check the location and try again. i feel that there is some problem in my web.xml file. i am not sure how to specify the <servlet-class> and <url-pattern> tags?? please help me out, thanks in advance [i am using Eclipse 2.1.2, Tomcat 5.0]
Praful Thakare
Ranch Hand
Joined: Feb 10, 2001
Posts: 613
posted
0
your formpack dir must be in /opt/tomcat/webapps/project/web-inf/classes and it must have formservlet.class file Cheers Praful
All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Sri Sar
Ranch Hand
Joined: Mar 25, 2004
Posts: 44
posted
0
Hi, thanks you very much for the prompt reply. i did as you directed and placed my formpack dir as you had mentioned. but still the same problem persists. when i enter a name in my HTML form and then click on submit, i still get the same error as before. i feel there are problems in specifying the parameters properly for <servlet-class> and <url-pattern> tags. is it possible for you to give an example of how the <serrvlet-class> and <url-pattern> tags should be mentioned (especially for files in local system)?? thanks in advance.
Praful Thakare
Ranch Hand
Joined: Feb 10, 2001
Posts: 613
posted
0
what url are you typing to access this servlet..or what is action value of attribute of your form tag ???also did u restarted the server after doing the changes
Sri Sar
Ranch Hand
Joined: Mar 25, 2004
Posts: 44
posted
0
Hi, yes, i restarted the server after making the changes. regarding the URL in the form tag, i have it given as: <form method="post" action="/hello">
Hi, please find below the contents displayed in the Console:
Jun 7, 2004 4:25:12 PM org.apache.coyote.http11.Http11Protocol init SEVERE: Error initializing endpoint java.net.BindException: Address already in use:8080 ...... Jun 7, 2004 4:25:12 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 2314 ms Jun 7, 2004 4:25:12 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Jun 7, 2004 4:25:12 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/5.0.16 Jun 7, 2004 4:25:12 PM org.apache.catalina.core.StandardHost start INFO: XML validation disabled Jun 7, 2004 4:25:13 PM org.apache.catalina.startup.ContextConfig applicationConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/DemoProject] Jun 7, 2004 4:25:13 PM org.apache.commons.digester.Digester fatalError SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. ........ Jun 7, 2004 4:25:13 PM org.apache.catalina.startup.ContextConfig applicationConfig SEVERE: Parse error in application web.xml org.xml.sax.SAXParseException: Content is not allowed in prolog. .... Jun 7, 2004 4:25:13 PM org.apache.catalina.startup.ContextConfig applicationConfig SEVERE: Occurred at line 1 column 1 Jun 7, 2004 4:25:13 PM org.apache.catalina.startup.ContextConfig start SEVERE: Marking this application unavailable due to previous error(s) Jun 7, 2004 4:25:13 PM org.apache.catalina.core.StandardContext start SEVERE: Error getConfigured Jun 7, 2004 4:25:13 PM org.apache.catalina.core.StandardContext start SEVERE: Context startup failed due to previous errors Jun 7, 2004 4:25:14 PM org.apache.catalina.startup.ContextConfig applicationConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/srikanth] Jun 7, 2004 4:25:14 PM org.apache.commons.digester.Digester endElement SEVERE: End event threw exception java.lang.reflect.InvocationTargetException
i have listed only a snapshot of the console contents which i feel could be useful. there is a line that says XML Validation disabled.. does this have something to do with my errors?
This question will be best answered in the Tomcat forum. This forum is for Servlets questions, and since your question is not about Servlets, I am going to move it to the Tomcat forum.
Means that tomcat is starting on port 8080, but fails to do so, because something else is already using this port. NO jsps will work if this is the case; Tomcat has failed to start at all.
You have a bad character in an XML file (probably server.xml or web.xml). Check to be sure that you haven't used Microsoft Word to create these documents, and that they don't have any 'special' characters. Open the files in a text editor (or better, a validating XML editor) and ensure they are all well-formed.
Finally.. I'm not an Eclipse user, so I can't help with Eclipse/Tomcat. Are you using Eclipse as an IDE, and then using a separate stand-alone tomcat instance to test your work ?
Sri Sar
Ranch Hand
Joined: Mar 25, 2004
Posts: 44
posted
0
Hi, thanks for the reply. i am not using a separate stand-alone tomcat instance to test my work. in Eclipse, i have installed a special Tomcat plug-in from Sysdeo. also i am working on the things u suggested.
Sri Sar
Ranch Hand
Joined: Mar 25, 2004
Posts: 44
posted
0
Hi, thanks for the reply. as suggested by you, since there is a line in my tomcat console that says: java.net.BindException: Address already in use:8080 i am trying to change the port to say 8081 etc... to see if it works.
also, in my server.xml file in tomcat>conf, i have the following content: <!-- <Context path="" docBase="ROOT" debug="0"> -->
has this to do something with my errors and if i uncomment the above, will my application work?? thanks in advance.
how is your application configured in tomcat's server.xml ?
It should have its own context.
Also, how are you calling it from the address bar? (What is the address you type in?)
Sri Sar
Ranch Hand
Joined: Mar 25, 2004
Posts: 44
posted
0
Hi, i changed my default port to 8085 and this works fine. but it seems that there is some problem with my web.xml i am posting below some key points in my Tomcat log:
Jun 10, 2004 11:10:31 AM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on port 8085 Jun 10, 2004 11:10:32 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 2372 ms Jun 10, 2004 11:10:32 AM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Jun 10, 2004 11:10:32 AM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/5.0.16 Jun 10, 2004 11:10:32 AM org.apache.catalina.core.StandardHost start INFO: XML validation disabled Jun 10, 2004 11:10:32 AM org.apache.catalina.startup.ContextConfig applicationConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/DemoProject] Jun 10, 2004 11:10:33 AM org.apache.commons.digester.Digester fatalError SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. Jun 10, 2004 11:10:33 AM org.apache.catalina.startup.ContextConfig applicationConfig SEVERE: Parse error in application web.xml org.xml.sax.SAXParseException: Content is not allowed in prolog. Jun 10, 2004 11:10:33 AM org.apache.catalina.startup.ContextConfig applicationConfig SEVERE: Occurred at line 1 column 1 Jun 10, 2004 11:10:33 AM org.apache.catalina.startup.ContextConfig start SEVERE: Marking this application unavailable due to previous error(s) Jun 10, 2004 11:10:33 AM org.apache.catalina.core.StandardContext start SEVERE: Error getConfigured Jun 10, 2004 11:10:33 AM org.apache.catalina.core.StandardContext start SEVERE: Context startup failed due to previous errors Jun 10, 2004 11:10:33 AM org.apache.commons.digester.Digester fatalError SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. Jun 10, 2004 11:10:33 AM org.apache.catalina.startup.ContextConfig applicationConfig Jun 10, 2004 11:10:33 AM org.apache.catalina.startup.ContextConfig applicationConfig SEVERE: Occurred at line 1 column 1 Jun 10, 2004 11:10:33 AM org.apache.catalina.startup.ContextConfig start SEVERE: Marking this application unavailable due to previous error(s) Jun 10, 2004 11:10:33 AM org.apache.catalina.core.StandardContext start SEVERE: Error getConfigured Jun 10, 2004 11:10:33 AM org.apache.catalina.core.StandardContext start SEVERE: Context startup failed due to previous errors Jun 10, 2004 11:10:33 AM org.apache.catalina.startup.ContextConfig applicationConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/srikanth] Jun 10, 2004 11:10:34 AM org.apache.catalina.startup.ContextConfig applicationConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TomcatProject] Jun 10, 2004 11:10:34 AM org.apache.catalina.startup.ContextConfig applicationConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Inputserv] Jun 10, 2004 11:10:34 AM org.apache.catalina.startup.ContextConfig applicationConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SriProj] SEVERE: Parse error in application web.xml org.xml.sax.SAXParseException: Content is not allowed in prolog.
the same errors are repeatedly displayed in the log. i am not able to figure out on how to proceed? what should i do now? thanks in advance
INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/DemoProject] Jun 10, 2004 11:10:33 AM org.apache.commons.digester.Digester fatalError SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog.
Also, you still have an error in *some* web.xml file. There is one that is shared between all web apps. In TC4 it's in the conf directory. Confirm that web.xml is not corrupt, and validates properly.
Sri Sar
Ranch Hand
Joined: Mar 25, 2004
Posts: 44
posted
0
Hi, thank you for the reply. as per ur suggestions, i have checked the web.xml file in conf folder of tomcat (my version is 5.0) the directory tree for my application is:
tomcat - webapps - prog - WEB-INF - classes - lib - src - web.xml - fopack -formserv.class (fopack is the package present in classes folder and under fopack, formserv.class is located)
also i have another doubt: a small portion of my server.xml file is given below: in this, the xmlValidation="false" is given. can i change it to xmlValidation="true"?? <!-- Define the default virtual host Note: XML Schema validation will not work with Xerces 2.2. --> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
in the URL given above, the corresponding code is: <!-- Define the default virtual host --> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">
<!-- Add the following attributes if you want to turn XML validation on. Remember to comment the Host element above.
Note: XML Schema validationn will works with Xerces 2.0.1 or Xerces 2.1. Xerces 2.0.2 and Xerces 2.2 have bugs that prevent their use with Tomcat--> <!-- <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="true" xmlNamespaceAware="true"> -->
thanks in advance and waiting to hear from you. [ June 11, 2004: Message edited by: Sri Sar ]