File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot bring up a html page using tomcat 6.0

 
vijay kaaman
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am on windows 7.

I have this "form.html" in the following directory location.

C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\Beer-v1\form.html

I believe I have tomcat started.
Navigated to.. C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin and ran the Tomcat6w as administrator.

I used the following URLs..
http://localhost:80/Beer-v1/form.html
http://localhost:8080/Beer-v1/form.html
http://localhost/Beer-v1/form.html

Tried this on IE and Google chrome.

Keep getting the error..
HTTP Status 503 - This application is not currently available

--------------------------------------------------------------------------------

type Status report

message This application is not currently available

description The requested service (This application is not currently available) is not currently available.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.33
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that all there is to Beer-v1, or did you structure the directory in WAR format, including a WEB-INF/web.xml file?
 
sagar kumar nerella
Greenhorn
Posts: 18
Java Notepad Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first of all
check for the typing errors in web.xml
or
the tag matching
most of the times this only gives error
 
vijay kaaman
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a web.xml in the "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\Beer-v1\WEB-INF" directory.

This is what I have in web.xml

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmln:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version = "2.4">

<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>

</servlet-mapping>

</web-app>

I have the following code in BeerSelect.java and is placed in "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\Beer-v1\WEB-INF\classes\com\example\web" directory. The BeerSelect.class file is also present in this directory.

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet {

public void doPost(HttpServletRequest request,
HttpServletResponse response
) throws IOException, ServletException{

response.setContentType("text/html");

PrintWriter out = response.getWriter();

out.println("Beer Selection Advice<br>");

String c = request.getParameter("color");

out.println("<br> Wants beer color "+ c);
}

}

This is the code in form.html

<html>
<body>
<h1 align="center">Beer Selection Page </h1>
<form method = "POST" action="SelectBeer.do">Select beer characteristics<p>

Color:<select name="color" size="1">
<option value="light">light</option>
<option value="amber">amber</option>
<option value="brown">brown</option>
<option value="dark">dark</option>
</select>

<br>
<br>

<center>
<input type = "SUBMIT">
</center>

</form>
</body>
</html>

 
Tim Moores
Bartender
Pie
Posts: 2488
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the correct URL, the others won't work unless you have done some modifications in your Tomcat setup: http://localhost:8080/Beer-v1/form.html

Check the files in the logs directory for error messages, especially the catalina* files; something should be in there.
 
vijay kaaman
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find the following error message.

Nov 17, 2011 11:15:37 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory Beer-v1
java.lang.UnsupportedClassVersionError: com/example/web/BeerSelect : Unsupported major.minor version 51.0 (unable to load class com.example.web.BeerSelect)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2822)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:108)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:58)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1078)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4612)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

in the catalina.* file
 
Tim Moores
Bartender
Pie
Posts: 2488
4
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That means you're using a newer Java version (Java 7, specifically) to compile the code than Tomcat uses to run it. The best way to address this is to uninstall all but one JDK from your machine. Whether you choose to keep Java 7 -or maybe Java 6- is up to you; both should work.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:The best way to address this is to uninstall all but one JDK from your machine. Whether you choose to keep Java 7 -or maybe Java 6- is up to you; both should work.


No it's not. This isn't Microsoft, where you can have only one IE. Java is very expressly designed to allow as many different JDK and JVM versions on a machine as you can stand. And (for better or worse), sometimes for business purposes, it's a necessary advantage.

The JDK that's used by Tomcat is the one that is defined by the JAVA_HOME environment variable for the command shell (or equivalent) that's running Tomcat. Want a different JVM? Change that shell's JAVA_HOME. Or create a TOMCAT_HOME\bin\setenv.bat and assign it there.

You can create Java 6-compatible classes without deleting JDKs, as well. The java compiler has options that set what version of Java the output classes should be compatible with. Java is extremely big on backwards compatibility. Or you can just specify the desired compiler JDK in the build process.
 
Tim Moores
Bartender
Pie
Posts: 2488
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gotta disagree with your disagreement. For someone working at the level of that kind of problem it's almost certainly better (less confusing) not to keep multiple JDKs/JREs installed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic