Hiren,
If this question has been answered already, I apologize. I can't tell how
old the message is since the date of the email is incorrect b/c the time is
not set properly on your machine.

The solution seems to me to be to put the method that is currently in your
servlet class into a static method in a separate class so that it can be
shared more easily between your servlets and JSP pages. Another, less
desirable option would be to make the method static in your servlet class
so that you can invoke it from your JSP without creating an instance
variable of the servlet class in your JSP.

Regards,

Richard

At 08:24 PM 1/19/2002 -0500, you wrote:
>hello richard,
>
>i meant invoking methods on the servlet on receiving request from a jsp
>page.
>for example, i have method called registerUser(String username, String
>password) in the servlet class.
>how to invoke this method from a jsp page on user clicking the Submit button
>?
>thanks for your help.
>
>
>
>-----Original Message-----
>From: A mailing list for discussion about Sun Microsystem's Java Servlet
>API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
>Richard Yee
>Sent: Wednesday, June 26, 2002 7:45 PM
>To: [EMAIL PROTECTED]
>Subject: Re: methods on a servlet
>
>
>Dossani,
>Yes, it is possible to invoke methods in a servlet class from a jsp page.
>You need to import the servlet's class if it is in a package. What method
>do you want to invoke? You shouldn't invoke any of the methods defined by
>the HttpServlet interface. You would treat the servlet just like any other
>class whose method's you want to invoke. You would need to create an
>instance of the class unless the method is static. This would all be done
>in a scriptlet.
>
>Now just because you can do it, doesn't mean you should. A better approach
>would be to put the method in its own class which would then be imported
>and instantiated by the servlet or JSP as a bean.
>
>Regards,
>
>Richard
>
>
>
>
>At 05:08 PM 6/26/2002 -0600, you wrote:
> >hello,
> >is it possible to invoke methods in a servlet class from a jsp page ?
> >thanks for your help.
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to