This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP file and java class in the same package Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "JSP file and java class in the same package" Watch "JSP file and java class in the same package" New topic
Author

JSP file and java class in the same package

sree hareesh
Greenhorn

Joined: Nov 16, 2011
Posts: 11
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

Joined: Jan 10, 2002
Posts: 56191
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1004
>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.



 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JSP file and java class in the same package
 
Similar Threads
Apache/Jserv Urgent Please!
Is it mandatory to put a bean inside a package?
packages in Kawa 3.5
packages
Problem with JspC taskdef