webapp runs on Sun AS, not on SunONE 6.1SP5 ?
Hi there,
I'm very new when it comes to Java Enterprise programming so I tried following
a few examples which guided me in setting up a web application using Netbeans.
My "application" consist of 2 .jsp pages and one supporting java class. The
index.jsp asks the user to enter his name, then the second page displays the
given name.
When I finish and run this project it works perfectly on the Sun Application
Server 8.2 (Platform Edition, the one shipped with J2EE 1.4) but when I try to
deploy the .war file to the SunONE server I get an error during deployment:
[https-magi.intranet.lan]: info ( 1290): WEB0100: Loading web module in virtual
server [www.intranet.lan] at [/intraApp]
[https-magi.intranet.lan]: failure ( 1290): ContextConfig[/hello] WEB3524:
Parse error in application web.xml
org.xml.sax.SAXParseException: Element type "web-app" is not declared. at
org.apache.crimson.parser.Parser2.error(Parser2.java:3354) at
org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1502) at
org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667) at
org.apache.crimson.parser.Parser2.parse(Parser2.java:337) at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) at
org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223) at
javax.xml.parsers.SAXParser.parse(SAXParser.java:314) at
javax.xml.parsers.SAXParser.parse(SAXParser.java:89) at
---<Cut>---
Well, first hint would ofcourse be 'web.xml' which is seemingly missing an
element type ("web-app") but as you can see below its actually declared.
So now I'm wondering if there are any specific differences between the two
servers which I should keep in mind. I did notice that SunONE supports JDK
1.4.1_03 so I do understand as much that using specific JDK 1.5 methods are
likely to fail (my netbeans environment uses 1.5). But from what I read so far
its my understanding that it shouldn't be a problem to use JDK 1.5 to create
applications for a 1.4 platform as long as you don't use these specific
methods.
For the record I'll include my demo files here, the whole structuring of the
..war file is something I left in the hands of Netbeans for now. I think its
safe to conclude that it does a good job, I conclude as much that the
application runs as expected on the Sun Application server.
Thanks in advance for any comments....
--=[ web.xml - note: long lines have been cut with \ ]=--
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com \
/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
--=[ EOF ]=--
And here is the actual program:
--=[ index.jsp ]=--
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Name request form</title>
</head>
<body>
<h1>Please tell us your name...</h1>
<form name="form1" action="response.jsp">
Please enter your name: <input type="text" name="name" value="" />
<input type="submit" value="GO" />
</body>
</html>
--=[ EOF ]=--
--=[ response.jsp ]=--
.... (see above example for everything in the head)
<body>
<h1>We've caught your name...</h1>
<jsp:useBean id="mybean" scope="page" class="org.catslair.GetName" />
<jsp:setProperty name="mybean" property="name" />
Your name is <jsp:getProperty name="mybean" property="name" /> !
</body>
</html>
--=[ EOF ]=--
And finally the supporting Java class:
--=[ GetName.java ]=--
package org.catslair;
public class GetName {
private String name;
public GetName() {
setName(null);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} // end of class
--=[ EOF ]=--
--
Groetjes, Peter
..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc