Load new page when succesfully logged in "JSP java" -
We created a login page, where the user can enter a username and password, while clicking on the login, When clicking on the "Nominated" button you can use some advice about loading a new page.
My code is now from "validatelogin" But it does not really work properly. I think that you have PHP Because you are setting the header Just setting the location header does not work with JSP.
& lt;% @ page language = "java" contentType = "Text / html; charset = ISO-8859-1" page encoding = "ISO-8859-1" import = "Java.O., Java.uppress. *"% "& Lt ;! DOCTYPE HTML PUBLIC" - / / W3C // DTD HTML 4.01 transcription // n "" http://www.w3.org/TR/html4/loose.dtd">" gt; gt; top & gt; & lt; Meta http-equiv = "content-type" content = "text / html; Charset = ISO-885 9 -1 "& gt; & gt; title & gt; insert the title here & lt; / title & gt; & lt; / head & gt; & lt; body & gt; & lt;% String UID, pass; Uid = request.getParameter ("userid"); pass = request.getParameter ("password"); if ("mk 123". Amends (uid) and amp; amp; amp ; 1234 & amp; nbsp;; equal (pass)) {// SLT Attitant "Login Inn" session session. Settet ("Login", "Yes"); out.println ("You have successfully logged in & lt ; Br & gt; "); // string site = new string (" http: // localhost: 8080 / CDIO3 _-_ gruppe17 / ScaleWeb.jsp ") again New location to be directed; Response.setHeader ("location", site);} other {// fjern attributten "logget ind" fra sessionen session.removeAttribute ("log in"); out.println ("incorrect user id or Password. & Lt; br & gt; ");}% & Gt; enter & lt; a href =" ScaleWeb.jsp "& gt; Protected page & lt; / a & gt; or & lt; a href = "Login. Jsp "& gt; Back to page & lt; / a & gt; & lt; / body & gt; & lt; / html & gt;
response.setHeader (instead of "location", site); :
response.sendRedirect (site); return ;
Comments
Post a Comment