Help - How to use a Class I have done?

A

AntoS

I'm beginning to develop using JSP, or better I would like...I prepared a
Class in JAVA and I compiled it, now I got MyClass.class file, and now...

How can use the method inside this class on my webPage? What do I have to
write on the page?

Something like <%@ import "???.MyClass.*" %>

but what exactly?

Thanks
 
K

Kevin Hooke

You'll need an import statment like:
<%@ page import="yourpackage.*" %>

or
<%@ page import="yourpackage.MyClass" %>

And then you can either instantiate it in scriptlet code like this:
<%
MyClass instance1 = new MyClass();
instance1.myExampleMethod();
%>

Or instantiate it with a <jsp:useBean> tag, like this:
<jsp:useBean id="instance1" type="youpackage.MyClass" scope="request"/>

Hope that helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,688
Members
48,796
Latest member
Greg L.

Latest Threads

Top