aspose file tools*
The moose likes Tomcat and the fly likes Cannot bring up a html page using tomcat 6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Cannot bring up a html page using tomcat 6.0" Watch "Cannot bring up a html page using tomcat 6.0" New topic
Author

Cannot bring up a html page using tomcat 6.0

vijay kaaman
Greenhorn

Joined: May 18, 2011
Posts: 5
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

Joined: Jun 25, 2001
Posts: 16145
    
  21

Is that all there is to Beer-v1, or did you structure the directory in WAR format, including a WEB-INF/web.xml file?


Customer surveys are for companies who didn't pay proper attention to begin with.
sagar kumar nerella
Greenhorn

Joined: Jul 09, 2011
Posts: 18

first of all
check for the typing errors in web.xml
or
the tag matching
most of the times this only gives error


sagar kumar nerella,
java certified professional
vijay kaaman
Greenhorn

Joined: May 18, 2011
Posts: 5
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: May 18, 2011
Posts: 5
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jun 25, 2001
Posts: 16145
    
  21

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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot bring up a html page using tomcat 6.0