aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
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: 60077
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
>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://aspose.com/file-tools
 
subject: JSP file and java class in the same package
 
Similar Threads
Is it mandatory to put a bean inside a package?
Apache/Jserv Urgent Please!
packages in Kawa 3.5
Problem with JspC taskdef
packages