Solved

Java Filter

Posted on 2009-07-10
4
376 Views
Last Modified: 2013-11-24
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
Comment
Question by:ChrisOz2008
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 250 total points
ID: 24824059
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
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 250 total points
ID: 24824082
You should be able to use:
request.getRequestURI();
// or...
javax.servlet.http.HttpUtils.getRequestURL(request);

Open in new window

0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24824106
Yes, request.getRequestURL() not request.getRequestURI() although that is valid too if you want the URI instead.
0
 

Author Closing Comment

by:ChrisOz2008
ID: 31602091
Thanks guys :)

Chris
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
strDist challenge 35 133
maven java path setting 5 64
eclipse apache tomcat admin console 52 150
program arguments vs VM arguments 4 28
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question