What directory to put bean classes on application server PE9
Hello Everyone,
I am new to Java EE and I am in need of a little assistance. I am in the middle of a JSP tutorial and it is teaching how to apply the <jsp:useBean> tag however I am unsure of where to put my complied bean classes on the server so that it can find them. Is there a special folder that is on the server's class path in which to place these? if not what is the default classpath of the server and how do I change it to include the folder that I have my bean classes in?
Much Thanks in advance,
Robert
# 1
Here is the stack trace from the server that is produced when the form from the tutorial tries to find my bean.
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
[javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\__default-web-module-server\org\apache\jsp\wordpro_jsp.java:55: cannot find symbol
[javac] symbol : class SpellCheck
[javac] location: class org.apache.jsp.wordpro_jsp
[javac]SpellCheck help = null;
[javac]^
Generated servlet error:
[javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\__default-web-module-
server\org\apache\jsp\wordpro_jsp.java:57: cannot find symbol
[javac] symbol : class SpellCheck
[javac] location: class org.apache.jsp.wordpro_jsp
[javac] help = (SpellCheck) _jspx_page_context.getAttribute("help", PageContext.REQUEST_SCOPE);
[javac]^
Generated servlet error:
[javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\__default-web-module-server\org\apache\jsp\wordpro_jsp.java:60: cannot find symbol
[javac] symbol : class SpellCheck
[javac] location: class org.apache.jsp.wordpro_jsp
[javac] help = (SpellCheck) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "SpellCheck");
[javac] ^
[javac] 3 errors
and here is the code
First here is the form that requests the wordpro.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Bean Input</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="wordpro.jsp" method="post">
Enter Word:
<input type="text" name="word">
<select name="mode">
<option value="1" selected> Reverse</option>
<option value="2">Spellcheck</option>
</select>
<input type="submit" name="Go" value="Submit">
</form>
</body>
</html>
The here is the wordpro.jsp which in return trys to use the SpellCheck bean.
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="help" scope="request" class="SpellCheck" />
<jsp:setProperty name="help" property="*"/>
<html>
<head>
<title>WordPro</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
You entered the input, <b> <%= request.getParameter("word") %></b>
The process output is:
<%= Integer.parseInt(request.getParameter("mode")) == 1 ? help.reverse() : ""+help.check() %>
</body>
</html>
Then finally here is the bean itself
public class SpellCheck{
private String word;
public SpellCheck(){
}
public String reverse(){
return (new StringBuffer(word).reverse()).toString();
}
public boolean check(){
return true;
}
public String getWord(){
return word;
}
public void setWord(String aWord){
word = aWord;
}
}
I currently have the bean in the docroot folder on the server but I know this is not right. Where do I put the bean so that it can be seen on the class path? Also once I have done this how do I point the useBean tag to the folder that the bean is in because I know that just putting the class name like this won't work. <jsp:useBean id="help" scope="request" class="SpellCheck"/>. It seems to be looking for my bean class in the wordpro.jsp right now at least that is what I get from the stack trace.
Again thanks in advance,
Robert
P.S. I tried creating my own folder and putting it on the path which is what one article I read suggested, but that didn't seem to work. I guess until someone can help me by answering my question I will use a simpler application server. I found one called Blazix at www.blazix.com/download.html that tells in the documentation that the classes folder is the default folder for beans.
Message was edited by:
robert_t_stone