Following is the
jsp page, which is rendered when client contacts the server for the page (Usually it should be HTML page). In this jsp page , there is
java code which requires info from the client to be filled in the fields and that info is processed on the server. Now when this page is rendered at the first request only, there is no info available from the client as yet. So how will java code in jsp be executed (
String userName = request.getParameter("username"); String password = request.getParameter("password");) ? Since there is no object available, will not it throw null pointer exception ? If no, then why not ? where will the values for username and password come from ?
----------------------------------------------------------------------------------------------------
<%@ page language="java" import="java.util.*" %>
<%
////////////// get the login information:
String userName = request.getParameter("username");
String password = request.getParameter("password");
////////////// and save it in the session:
session.setAttribute("username", userName);
%>
<html>
<body>
Welcome, <%=userName%>!
<form action="..." method="get">
....
</form>
</body>
</html>
--------------------------------------------------------------------------------
thanks