Session tracking in servlets and jsp -
i have first created login panel(index.jsp) in jsp,where user enters username , password on submit goes servlet(login) checks authenticity of user , takes home page after validating(home.jsp).
i want store user information after he/she logs in implemented seession in servlet(login) follow
response.sendredirect("shome.jsp"); httpsession sr=request.getsession(true); sr.setattribute("no", u); (u string variable)
now how can retreive value of no in home.jsp?
no should within quotes.
sr.setattribute("no", u); in jsp provide this
<% string username=(string)session.getattribute("no"); %> and use string username in anywhere in jsp
example
<h1>your user name is: <%=username%>.</h1>
Comments
Post a Comment