Java – change JSP button click
•
Java
I have a question
I have three JSP pages The first is a menu with two buttons When I click the first button, I want to open the second JSP page When I click the second button, I want to open the third JSP page
Can you help me? I have to use a servlet (that's not a problem, I know)?
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <Meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form name="TrainerMenu" action="TrainerMenu" method="get"> <h1>Benvenuto in LESSON! Scegli l'operazione da effettuare:</h1> <input type="button" value="Creazione Nuovo Corso" name="CreateCourse" /> <input type="button" value="Gestione Autorizzazioni" name="AuthorizationManager" /> </form> </body> </html>
Solution
You have several choices. I'll start with the simplest aspects:
1 - change the input button to a link, and you can style it with CSS to make it look like a button:
<a href="CreateCourse.jsp">Creazione Nuovo Corso</a>
replace
<input type="button" value="Creazione Nuovo Corso" name="CreateCourse" />
2 - use JavaScript to change the operation of the form according to the button you click:
<input type="button" value="Creazione Nuovo Corso" name="CreateCourse" onclick="document.forms[0].action = 'CreateCourse.jsp'; return true;" />
Use servlet or JSP to process the request and redirect or forward it to the corresponding JSP page
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码