Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

Java Filter

I have a filter class that i use to monitor whether or not a user is logged in. My issue is that due to some limitation/requirement or RichaFaces I need to be able to only manage specific URLs in my filter. It seems that when a user types for example www.myapp.com/myContext/mypage.jsp  RichFaces is messing around with the request and so if I try to perform some logic on the request it is failing.

How can I write my code to determine the URL of the incoming request? I'm guessing it will be something like this:

request.getURL();
if (URL = <my site URL>)
   // do some forwarding logic
else continue as usual.

Thanks for any advice :)


Chris
0
ChrisOz2008
Asked:
ChrisOz2008
  • 2
2 Solutions
 
rrzCommented:
Maybe something like the following.
public void doFilter(ServletRequest req,ServletResponse resp,FilterChain chain)
                   throws ServletException, IOException {
                          HttpServletRequest request = (HttpServletRequest)req;
                          String url = request.getRequestURL();
                          if(!"<my site URL>".equals(url))chain.doFilter(req, resp);
                          else  // do some forwarding logic
  }

Open in new window

0
 
Kevin CrossChief Technology OfficerCommented:
You should be able to use:
request.getRequestURI();
// or...
javax.servlet.http.HttpUtils.getRequestURL(request);

Open in new window

0
 
Kevin CrossChief Technology OfficerCommented:
Yes, request.getRequestURL() not request.getRequestURI() although that is valid too if you want the URI instead.
0
 
ChrisOz2008Author Commented:
Thanks guys :)

Chris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now