aspose file tools*
The moose likes JSP and the fly likes How to invoke a class from a JSP? 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 » JSP
Bookmark "How to invoke a class from a JSP?" Watch "How to invoke a class from a JSP?" New topic
Author

How to invoke a class from a JSP?

Darko Markovic
Greenhorn

Joined: Sep 15, 2013
Posts: 16

I'm trying to get some information from a database in my application. I have a class with an execute method that uses request.getParameter("username"). The problem is, I don't know how to invoke the class directly from the JSP. I know that in Struts, I use an action path in a form, and I need an actionform class, and an action class that uses the form information. In this case, I only need the information from the request, and not a form, So I don't want an empty form in my application. To sum up, I need a way to invoke a class with an execute method that uses request information directly from the JSP.

Thanks in advance,
Darko


One cannot simply use scriptlets in JSP. And also, mycaruba.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Modern JSPs do not contain Java code. Rather, your class should be called by the page controller for the JSP, and any data that the JSP needs be placed in request scope so that, on the JSP, the JSTL and EL can be used to display it.

Please read this article to understand how modern web applications are structured.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to invoke a class from a JSP?