I want to pass some parameters from my java servlet to my html form to be shown. I have read some things about jsp but I was wondering if I can do it directly, using something like this :
<script> var temp = "${param['CookieServlet0.First_Name']}"; </script>
<input type = "text" name = "First_Name" id = "First_Name" value = "temp" > <br>
where First_Name is a parameter of my servlet CookieServlet0. I know that the code example is wrong, is there a way to fix it so that I won't have to use jsp?
EDIT : ok since there is no way around I am starting with jsp, I've checked what you guys sent about JSTL and I do not need the extras that it offers so I am trying to keep it simple since I am just starting. So I have written the code below but I get java.lang.NullPointerException. It must be something really obvious but I cannot see what I do wrong...all the tutorials I have seen use the exact same commands...
java servlet :
 public void doGet( HttpServletRequest request,        // reaction to the reception of GET
                  HttpServletResponse response )
                  throws ServletException, IOException
   {
    String First_Name = request.getParameter("First_Name");
    String Last_Name = request.getParameter("Last_Name");
    String Phone_Number = request.getParameter("Phone_Number");
    String Address = request.getParameter("Address");
    PrintWriter output;
    Cookie cookies[];
    cookies = request.getCookies(); // get client's cookies
    if ( cookies.length != 0 ) {                                               
        String departure = cookies[0].getValue();
        String destination = cookies[1].getValue();
    }
    request.setAttribute("First_Name",First_Name);
    String strViewPage="formB.jsp";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(strViewPage);
    dispatcher.forward(request, response);
 }
formB.jsp
<%@ 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>
<label for = "First Name"> First Name </label>
<input type = "text" name = "First_Name" id = "First1_Name" value = "${First_Name}" 
"> <br>
</body>
</html>
 
     
     
    