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.
>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.