0

What i want to do is create a login page with jsp. I have never used jsp before so i did some research on it, and learned how to use java beans en java code mixed with html. So i can send the inputs from the login jsp to another jsp page and retrieve the data with request.getParameter(), but my question is how can i call a method from the java bean/class.

The method checks if the login data is legit or not. I want to call the method in the same jsp page as the login form, is that possible?

<%@<jsp:useBean id="service" class="FavoriteService" scope="session"/>
" %>

This is how i declared/initialised my class in the login jsp page

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Kupi
  • 903
  • 1
  • 10
  • 16

1 Answers1

0

Put your logic code inside a servlet, and map it to /login URL for example (via web.xml). Before forwarding the request from the servlet to the JSP file (request.getRequestDispatcher("/login").forward(request, response)), you can pass the result of the logic code via request.setAttribute("SomeKey", someResult) method. Inside the JSP file, you can access the request attribute via EL expression (${requestScope.SomeKey}).

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417