Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

this servlet run but not exactly....

 
 
gbattine
Guest
Posts: n/a
 
      07-23-2006
Hi guys,
i'm a problem and i don't find a solution from 10 days....please help
me.
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
time.
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();
visit.setUser(newUser);
visit.setAuthenticationBean(this);
setVisit(visit);
FacesContext facesContext = getFacesContext();
getApplication().createValueBinding("#{sessionScop e.visit}").setValue(facesContext,
visit);

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.*;

import java.io.Serializable;

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
authenticationBean)
{
this.authenticationBean = authenticationBean;
}

and this is my filter

package giu;

import java.io.IOException;
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,
ServletException
{
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() +
"/faces/Login.jsf");
httpResponse.sendRedirect(httpRequest.getContextPa th() +
"/faces/Login.jsf");
}
else
{
session.removeAttribute("originalTreeId");
String role = visit.getUser().getRole();
/*
if ((role.equals("utente") && requestPath.indexOf("protected") >
0))
{
String text = Utils.getDisplayString("ptrackResources",
"PathNotFound",
new Object[] { requestPath },
request.getLocale());
httpResponse.sendError(HttpServletResponse.SC_NOT_ FOUND,
text);
}
else*/
{
chain.doFilter(request, response);
}
}
Utils.log(servletContext, "Exiting the filter");
}

public void destroy()
{
}
}


with its declaration in web.xml

<filter>
<filter-name>AuthorizationFilter</filter-name>
<filter-class>giu.AuthorizationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthorizationFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AuthorizationFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>

Please help me.....

 
Reply With Quote
 
 
 
Reply

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 cormacdebarra@gmail.com 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



Advertisments