12. august 2003 - 20:42
Der er
15 kommentarer og 1 løsning
Beans and Tomcat 5.0.6
Hi all Could any one help me how to use java beans with Tomcat 5.0.6? My question is where to place java beans in Tomcat directory structure?. Thanks
Annonceindlæg fra Infor
12. august 2003 - 20:46
#1
webapps/yourapp/WEB-INF/classes/yourpackage/YourClass.class
12. august 2003 - 20:57
#2
Tomcat could not generate the class file i.e. could not compile the beans file. Thanks
12. august 2003 - 21:00
#3
No - you need to compile the servlets and the beans yourself. Tomcat will compile JSP pages. [at least that is how Tomcat 4 and the 3-4 other servers I have tried are doing it - I belive Tomcat 5 to be similar]
12. august 2003 - 21:18
#5
Sorry. jar-files is different - they should be in: webapps/yourapp/WEB-INF/lib/mylibrary.jar
12. august 2003 - 21:42
#6
Hi arne I try it but it does not help. The big question is: How jsp file can find the class file? (Throught the classpath or .xml file) Thanks your time
12. august 2003 - 21:54
#7
The server automatically set classpath to all jar files in the lib directory.
12. august 2003 - 22:04
#8
The jsp file could not find the bean class. And it shows an exception (classnotfound), that could not find the bean.
12. august 2003 - 22:14
#9
Kan du vise mig det relevant JSP kode og en listning af hvordan beanen ligger i jar filen ?
12. august 2003 - 22:14
#10
Sorry. Could you show me the relevant JSP code and a listing of how the bean are in the jar file ?
12. august 2003 - 23:15
#11
You are aware of that 5.0.6 is an alpha version ?
14. august 2003 - 10:24
#12
Hi Arne Sorry for the delay the following is the JSP code: <jsp:useBean id="formbean" class="FormBean"/> <jsp:setProperty name="formbean" property= "*"/> <HTML> <HEAD> <TITLE>Form Example</TITLE> </HEAD> <BODY BGCOLOR="#ffffcc"> <% if (request.getParameter("name")==null && request.getParameter("email") == null) { %> <CENTER> <H2>User Info Request Form </H2> <form method="GET" action="process2.jsp"> <P> Your name: <input type="text" name= "name" size=27> <p> Your email: <input type="text" name= "email" size=27> <P> <input type="submit" value="Process"> </FORM> </CENTER> <% } else { %> <P> <B>You have provided the following info</B>: <P> <B>Name</B>: <jsp:getProperty name= "formbean" property="name"/> <P> <B>Email</B>: <jsp:getProperty name="formbean" property="email"/> <% } %> </BODY> </HTML>
14. august 2003 - 12:24
#13
Og hvordan ligger FormBean.class i jar-filen ?
14. august 2003 - 12:58
#14
Following is the Bean code, which I make the jar file (jar cvf mybean.jar *.class). //package beans; import java.io.*; public class FormBean implements Serializable { private String name; private String email; public FormBean() { name = null; email = null; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setEmail(String email) { this.email = email; } public String getEmail() { return email; } }
14. august 2003 - 13:29
#15
Mit gæt er at det er et klassisk "no package" problem. Så prøv og: 1) indsæt package myutils; øvert i java filen. 2) flyt FormBean.java ned i et nyt directory myutils (myutils\FormBean.java) 3) compile igen 4) lav jar-filen med: jar cvf mybean.jar myutils\*.class 5) kopier mybean.jar til webapps\myappl\WEB-INF\lib 6) ret JSP til <jsp:useBean id="formbean" class="myutils.FormBean"/> 7) prøv igen
14. august 2003 - 19:23
#16
Thank you very much Arne. I succed got it.
Kurser inden for grundlæggende programmering