This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi! I am new to beans & jsp .I have following problem 1> I created a java file named counter and have used get & set methods. 2> I compiled the java file. 3>I created a jsp file named BeanCounter.jsp and used the counter class using the following code. <jsp:useBean id="counter" scope="session" class="Counter" /> 4> I placed all three files counter.java,counter.class & BeanCounter.jsp in Counter folder c:\tomcat\webapps\examples\jsp\Counter I get the following error Internal Servlet Error: org.apache.jasper.JasperException: Unable to load class Counter please help! Thanks in advance Chaitali
Class files do not go into the JSP directory! Don't forget that files in there can be requested by a client - you don't want everyone downloading your class files, do you? There should be a WEB-INF directory, probably tomcat/webapps/examples/WEB-INF (I don't know Tomcat that well). Class files go into WEB-INF/classes/. Don't forget to turn package names into subdirectories (i.e. com.chaitalid.MyClass would go into WEB-INF/classes/com/chaitalid/). Should you want to package your classes up in a jar file, the jar would go into WEB-INF/lib/. - Peter
[This message has been edited by Peter den Haan (edited May 14, 2001).]
"chaitalid", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements. Thanks.
First of all , you must place your class files in the class path of your server. Then the server will always load your custom class and make it available for use in your jsp. also if you are using package(looks like you kave your class in a package names counter), then you must instantiate the bean using <jsp:useBean id="counter" scope="session" class="counter.Counter" />