java - Jsf 2.2 with servlet filter -


I used JSF 2.2 and I have not used the session http session here.iam without having to login to JSF pages Want to redirect the page login to use the session variable scoped and check whether the whelther variable is blank or not and is trying to redirect it because the session scoped http session correct ??

My filter class is

 instead of enough  package com.invoice; Import java.io.IOException; Import javax.servlet.filter; Import javax.servlet.filterChain; Import javax.servlet.filterConfig; Import javax.servlet.ServletException; Import javax.servlet.ServletRequest; Import javax.servlet.ServletResponse; Import javax.servlet.annotation.WebFilter; Import javax.servlet.http.HttpServletResponse; / ** * Servlet filter implementation class session filter * / public class session filter tool filter {/ ** * default constructor * / public sessionfilter () {// TODO automatic build creator stub} / ** * @see filter # deleted () * / Public Deletion of Zero () {// TODO Automatic Created Method Stub} / ** * SEse Filter # doFilter (ServletRequest, ServletResponse, FilterChain) * / Public Zero DoFilter (ServletRequest Request, ServletResponse Response, FilterChain Series) throws IOException, ServletException {// TODO Auto Disable Method Method The stub // send here with your code in place // request Filter series Actiteepisrwlet response HTTPResponse = (Actiteepisrwlet Response) response; Login b = new login (); If (b.username == "") {httpResponse.sendRedirect ("Login.xhtml"); } And {chain.doFilter (request, response); }} / ** * @see filter #init (FilterConfig) * / Public Zero Init throws (FilterConfig fConfig) ServletException {// TODO Automatically created method stub}}  

My beans Here is

  package com.invoice; Import java.sql.Connection; Import java.sql.DriverManager; Import java.sql.ResultSet; Import java.sql.Statement; Import javax.faces.bean.SessionScoped; Import javax.faces.context.FacesContext; Public Class Login {String Username, User-powered, Underman, Navp; Public string getNavipg () {return navig; } Public Zero Satnewice (String Nouveau) {this.navipg = navipg; } Public string getErrormess () {return false; } Public Zero Set Earth (string flawed) {this.errormess = errormess; } Public string getUsername () {back username; } Public Zero Set USUN (String Username) {this.username = Username; } Public string getUserpassword () {return userpassword; } Public Zero Set User Powered (String User Password) {this.userpassword = userpassword; } Navigate public string (try {class.forName ("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection ("jdbc: oracle: thin: @localhost: 1521: XE", "invoice", "google"); Statement stmt = con.createStatement (); ResultSet rs = stmt.executeQuery ("Username, Password, Username = '" + Username + "' and password = '" + User Password "" "); if (rsnext ()) {setErrormess (" "); Navipg = "invoiceinfo";} Other {setErrormess ("Invalid Login Credentials"); Username = ""; navipg = "Login";}} Hold (Exception e) {e.printStackTrace ();} Return Navig;} Public string logout () {FacesContext.getCurrentInstance (). GetExternalContext (). Invalid session (); Return "Login";}}  

My web.fm filter tag

< Pre> & lt; filter & gt; & lt; filter-name & gt; s Essionfilter & lt; / filter-name & gt; & lt; filter category & gt; com.invoice.sessionfilter & lt; / filter class & gt; & lt; / filter & gt; & lt; filter-mapping & gt; & Lt; filter-name & gt; sessionfilter & lt; / filter-name & gt; & lt; url-pattern & gt; / jsf invoice system / * & lt; / url-pattern & gt; & lt; / filters - Mapping> Account

but the page is not being redirected

b .username == "" never be correct .

Required readings


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -