Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP file and java class in the same package

 
sree hareesh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have JSP file and java class in the same package, how can i use java class in JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't. Using Java code in a JSP has been obsolete since 2002.

Perform any Java code in the page controller servlet and use the JSTL and EL in the JSP. Any data you need can be placed in request scope by the controller, where the JSP will be able to easily access it.
 
Stefan Evans
Bartender
Posts: 1691
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>I have JSP file and java class in the same package

That just sounds horribly wrong.
JSPs don't belong in packages.
Your JSP code should be COMPLETELY separate from your java classes.

In a web application, your JSPs are resources to load.
Java classes are compiled, and are normally made available to a web app via the WEB-INF/classes directory, or a jar file in the WEB-INF/lib directory.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic