Calling a Class from a JSP file...

Discussion in 'Java' started by balgach@gmail.com, Apr 28, 2005.

  1. Guest

    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.
    , Apr 28, 2005
    #1
    1. Advertising

  2. JScoobyCed Guest

    wrote:
    > 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>

    --
    JSC
    JScoobyCed, Apr 28, 2005
    #2
    1. Advertising

  3. Malte Guest

    wrote:
    > 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.
    Malte, Apr 28, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    4,683
    Thomas Weidenfeller
    Oct 12, 2005
  2. Replies:
    1
    Views:
    526
    Andrea Desole
    Dec 14, 2005
  3. Duncan
    Replies:
    1
    Views:
    545
    Duncan
    Dec 20, 2005
  4. Replies:
    0
    Views:
    4,313
  5. Replies:
    8
    Views:
    3,395
    Manish Pandit
    Oct 11, 2006
Loading...

Share This Page