This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

where to put bean classes in JSP?  RSS feed

 
honey singh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm making an application using JSP and apache-tomcat server.
I'm putting the JSP pages in install_dir/webapps/ROOT directory and
the JSP page uses the Bean(FileUpload) defined in a package harman.upload and I had put the Bean in install_dir/webapps/ROOT/WEB-INF/classes/harman/upload
directory and I access the JSP page using the following URL
http://localhost:8080/FileUp.jsp
and uses the code in the JSP page
<jsp:useBean id="myUpload" scope="page" class="harman.upload.FileUpload" />
<%
myUpload.initialize(pageContext);
%>
but it gives me java.lang.NullpointerException.
I want to know if I'm right in putting the files in there desired places
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since JSP become servlets, classes used with JSP follow the same rules as classes used with servlets.
WEB-INF/classes for class files
WEB-INF/lib for jar files
You would have gotten a different error if it could not find the bean class file. If you have an errorPage defined for the JSP you can get a stack trace and then look at the created java code to figure out what is wrong.
Bill
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try instantiating the bean by hand rather than using use bean as it will show whether this is a class not found exception (problems with your classpath - it is the class file you put in, not the java file right?) or "wrong name" which means checking your file is in the right package and trying again, etc. If you have the full stack trace, that could help
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!