Calling a Class from a JSP file...

B

balgach

Hello all,

Im a relativly familiar java programmer, but quite new to JSP and i
have a basic (possibily dumb) question. I looked around on the web,
but didnt find anythign that really answered by question.

i have a java class MyClass.class

and i wish to make JSP pages that act as the inputs for functions in
this class. so in the JSP file i would want to do something like:




MyClass _item;


when the user hits a button the page it does seomthing like

_item.function(data_from_webpage); //in java.




which is basically just calling the java class from a JSP page. It
seems relativly simple (i would think)

Thanks,
Adam.
 
J

JScoobyCed

Hello all,

Im a relativly familiar java programmer, but quite new to JSP and i
have a basic (possibily dumb) question. I looked around on the web,
but didnt find anythign that really answered by question.

i have a java class MyClass.class

and i wish to make JSP pages that act as the inputs for functions in
this class. so in the JSP file i would want to do something like:




MyClass _item;


when the user hits a button the page it does seomthing like

_item.function(data_from_webpage); //in java.




which is basically just calling the java class from a JSP page. It
seems relativly simple (i would think)

Thanks,
Adam.

I suggest you to read some good tutorials (google can provide you this)
about JSPs.

<code>
myFile.jsp:

<%@page import="foo.pacakge.MyClass" %>

....html code

<%
MyClass _item = new MyClass();

_item.function(request.getParameter("item_id"));

%>
The result is: <%=_item.getResult()%>.

</code>
 
M

Malte

Hello all,

Im a relativly familiar java programmer, but quite new to JSP and i
have a basic (possibily dumb) question. I looked around on the web,
but didnt find anythign that really answered by question.

i have a java class MyClass.class

and i wish to make JSP pages that act as the inputs for functions in
this class. so in the JSP file i would want to do something like:




MyClass _item;


when the user hits a button the page it does seomthing like

_item.function(data_from_webpage); //in java.




which is basically just calling the java class from a JSP page. It
seems relativly simple (i would think)

Thanks,
Adam.
Additionally to the answer from Joshua you might want to look into the
concept of using beans.
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top