0

There are certain times where I have to output html code for errors/information e.g. "Password successfully updated" or "Login failed". When I use out.println, the message is just displayed at the top of the screen, how can I perhaps use a dialog box or position this text appropriately?

out.println("Employee Account Successfully Created");
                 RequestDispatcher rs = request.getRequestDispatcher("NewEmployee.html"); 
                 rs.include(request, response);
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Programmer
  • 1,266
  • 5
  • 23
  • 44

1 Answers1

0

My suggestion would to use jsp files in the request dispatcher, and request.setAttribute in the servlet.

For example, you might have something like:

request.setAttribute("result", "Employee Account Successfully Created");
RequestDispatcher rs = request.getRequestDispatcher("NewEmployee.jsp"); 
rs.forward(request, response);

Then in the JSP file:

<html>
<!- ...Some content /->

${result}

<!- ...Some more content /->
</html>
Hallrac
  • 36
  • 2