I would like to write a simple form in JavaEE. To do that I've created a simple form.jsp file. The code of this file is given below:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<% if(request.getAttribute("action")!=null) {
String action=(String) request.getAttribute("action");
if(action.equals("success")) { %>
<br>Added user correctly.</br>
<% } else { %>
<br>Error : <%=action %></br>
<% }
} else { %>
<u>Rejestracja:</u>
<form action="servletAgent" method="post">
<fieldset>
<table style="text-align: right;">
<tr><td>imie: </td><td><input type="text" style="width:220px" required="required" name="name" value=""></td></tr>
</table>
<center><input type="submit" value="Register"/></center>
</fieldset>
</form>
<% } %>
</body>
</html>
In this code we can see that I connect to "servletAgent". In "servletAgent.java" there is a method doPost(), where I check if the input name is correct if yes the information "Added user correctly" is displayed in other way the "Error" is displayed. Is there any other possiblity to do that, I mean is this method good to connect to servletAgent, maybe there is possiblity not to connect to servletAgent and do that in form.jsp file without any connection to servletAgent simplier?