I have an Jsp page that has the ID
text field which takes the input from the user and that input is read in a servlet. I am also validating that input in servlet. If user enters an wrong input I need to give a text message like wrong input below that ID
field only in the Jsp.
Here is the servlet code:
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
services2 reporteeservice = new services2();
services3 jiraservice = new services3();
service4 empid = new service4();
String id = request.getParameter("ManagerId");
int Number = 1;
PrintWriter out1=response.getWriter();
String n = ".*[0-9].*";
String a = ".*[a-z].*";
String c = ".*[A-Z].*";
if( id.matches(n) && id.matches(a) || id.matches(c))
{
out1.println("valid input");
try {
//s.getList(id);
....
}
else
{
out1.println("not a valid input");
}
But if I give else part as above, it will redirect me to next page and prints not a valid upon giving the wrong input. But, I want that to be displayed in the same page under the ID
field in the Jsp.
My JSP page:
<form name = "reportees" method = "GET" action="reportsto">
<center>
<h1><font size="20"> Enter the ID to get the Reportees</font></h1>
<label><font size="+2">ID</font></label>
<input name="ManagerId" ype="text" style="font-size:16pt"/>
<input type="submit" value="submit"/>
<button type="reset" value="Reset">cancel</button>
</center>
</form>