Davey
Davey

Reputation: 446

Calling a function on a servlet from a JSP page

I think my question title explains it all. It's for an assignment for school I have to do, I have to program some sort of bulletinboard. I figured out the useBean part more or less, and that it is used to call set properties. Only what if I want to call another function on the servlet which isn't a setter? How does that work?

Upvotes: 1

Views: 2111

Answers (1)

Only functions you can call from JSP to a Servlet are doGet() or doPost() as a result of a http request.

You can submit the the request from the JSP as follows:

response.sendRedirect("servleturl")

Or you can use a html <form>:

<form action="servletURL" method="post">

I would favor the second option if possible and try to avoid java code in your JSPs.

Upvotes: 1

Related Questions