Get String from one jsp to another jsp? -



Get String from one jsp to another jsp? -

i first create html file input username & passwword:

<body> <center> <h1>login section</h1> <form method="post" action ="getinfo.jsp"> username <input type="text" name="userid"><br> password <input type="password" name="pass"><br> <input type="submit" name="submit"> </form> </center> </body>

then first.jsp file receive username & password (check cookie also, runs fine):

<form method="get" action="showinfo.jsp"> <% string name = request.getparameter("userid"); string pass = request.getparameter("pass"); cookie pie = new cookie(name, "nothing_to_do_here"); pie.setmaxage(60 * 60 * 7); response.addcookie(pie); cookie[] cookies = request.getcookies(); boolean islogin = false; if (cookies != null) { cookie cookie; (int = 0; < cookies.length; i++) { cookie = cookies[i]; if (name.equals(cookie.getname())) { islogin = true; break; } } } if (islogin == true) { out.print("welcome " + name); } else { out.print("welcome " + name); } %> <a href="showinfo.jsp">click here</a> </form>

after click "click here" button, want show username & password returns null.

<body> <center> <h1>your id , password</h1> <% string id = (string)session.getattribute((string)"userid"); string pass = (string)session.getattribute((string)"pass"); out.print(id); out.print(pass); %> </center> </body>

anybody helps me show them please.

well, aren't setting session variables, you're trying them, need like session.setattribute("userid", "someuserid"); additionally, should utilize session store login information, not cookies. clients can view , edit cookies, current code have set cookie saying bob : nothing_to_do_here , application assume bob.

jsp

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -