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

JSP, Java Beans, and classes  RSS feed

 
Pete Albano
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a JavaServer page call a regular class, or do I have to create Java Beans to work with JSP?
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to javaranch Pete.
No, you can call any java class from a jsp/servlet. That's the advantage of using java technology. It is automatically added to your classpath by the servlet container if you place your class under the WEB-INF directory.
HTH
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must import your class first.
<%@ page import="java.util.ArrayList" %>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where your confusion may arise, is that to use a class via the <jsp:usebean> tag, it must follow (at least some of) the bean pattern.
However, for java classes that you are going to use in JSP scriptlets, any class can be used as has already been pointed out.
hth,
bear
[ August 24, 2003: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!