Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > this servlet run but not exactly....

Thread Tools

this servlet run but not exactly....

Posts: n/a
Hi guys,
i'm a problem and i don't find a solution from 10 days....please help
I have to give access security to my jsf application because each page
shows private information. I have a login page and a visit bean that
store the session's information,like current user and current locale.
I've developed a filter that when a page is loaded try to retrieve user
from Visit Object,if it's not found go to login page.
What's my problem?
After i developed my filter my application don't go well,because after
i logged in my application try to open next page but it loads for
infinite time....and while i try to load a page without log in i read
the messagge "indirizzamento a Login.jsf...." but it loads for infinite
It seems the filter acts but not exactly......
Can you help me?
I post you the important code.
This is the important code of mu AuthenticationBean

User newUser=new User(loginName,password,teamName,tipo);
Visit visit = new Visit();
FacesContext facesContext = getFacesContext();
getApplication().createValueBinding("#{sessionScop e.visit}").setValue(facesContext,

this is my Visit Object

package giu;

import javax.faces.context.FacesContext;
import java.util.Locale;
import javax.faces.model.SelectItem;
import javax.faces.application.Application;
import java.util.*;


public class Visit implements Serializable
private static final long serialVersionUID = 1L;
private User user;
private AuthenticationBean authenticationBean;

public Visit()

public User getUser()
return user;

public void setUser(User user)
this.user = user;

public AuthenticationBean getAuthenticationBean()
return authenticationBean;

public void setAuthenticationBean(AuthenticationBean
this.authenticationBean = authenticationBean;

and this is my filter

package giu;

import javax.servlet.*;
import javax.servlet.http.*;

public class AuthorizationFilter implements Filter
FilterConfig config = null;
ServletContext servletContext = null;

public AuthorizationFilter()

public void init(FilterConfig filterConfig) throws ServletException
config = filterConfig;
servletContext = config.getServletContext();

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException,
Utils.log(servletContext, "Inside the filter");

HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;
HttpSession session = httpRequest.getSession();

String requestPath = httpRequest.getPathInfo();
Visit visit = (Visit)session.getAttribute("visit");
if (visit == null)
session.setAttribute("originalTreeId", httpRequest.getPathInfo());
Utils.log(servletContext, "redirecting to " +
httpRequest.getContextPath() +
httpResponse.sendRedirect(httpRequest.getContextPa th() +
String role = visit.getUser().getRole();
if ((role.equals("utente") && requestPath.indexOf("protected") >
String text = Utils.getDisplayString("ptrackResources",
new Object[] { requestPath },
httpResponse.sendError(HttpServletResponse.SC_NOT_ FOUND,
chain.doFilter(request, response);
Utils.log(servletContext, "Exiting the filter");

public void destroy()

with its declaration in web.xml


Please help me.....

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Servlet Error]- not a servlet class Jitender Java 2 10-17-2007 02:24 PM
Servlet error ...package Javax.servlet does not exist Java 4 11-11-2006 01:55 PM
Exception in GUI Run but not in Simple RUN Andrea9 Java 1 10-20-2006 12:54 PM
seeking servlet "Master" keep getting "Master/servlet/Master" not found. Tomcat 5.0.25 Doug McCann Java 1 08-05-2004 09:16 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM