aspose file tools*
The moose likes Servlets and the fly likes how to import class into jsp file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to import class into jsp file" Watch "how to import class into jsp file" New topic
Author

how to import class into jsp file

Linda Xu
Ranch Hand

Joined: Feb 14, 2000
Posts: 51
Hi,
I compiled a class myClass and saved it into directory:
C\jrun\servlet
How can I declare an object of the type myClass in my jsp file.
my jsp file is stored in
C:\JRun\jsm-default\services\jws\htdocs\myJsp.jsp
Every time,I try to see this myJsp.jsp in browser, I get an error:
unknown type myNode
How to fix this? How to config class path for JSP files?
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Linda,
This is what you need to do:
<%@page import="className.class" %>
You need that double cotation and put the line in the top of the page, but under <%@page language=.... %>
regards
Ruilin
Raj Sharma
Greenhorn

Joined: Feb 06, 2001
Posts: 12
Hi,
You question is a little ambiguous.
If you want to create an instance of your class and use it's method, then other than an import, here is another approach.
Suppose the name of your file is OptionValues.java
Then in jsp page if you want to use this class and it's methods, then you should code,
<%OptionValues op = new OptionValues();
op.callMethod(); %>
Between <% and %> you can use any Java code.
Hope it helps.
Raj
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Raj,
You'd still need to import the class. It's not automatically available.

I should also mention that you don't put the .class extension on a page directive import statement, and that multiple imports are separated by commas.

<%@page import="java.util.*,com.yourCompany.yourLibarary.*" %>
[This message has been edited by Mike Curwen (edited May 23, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to import class into jsp file