Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


getting anchor tag from HttpServletRequest

Posted on 2005-03-29
Medium Priority
Last Modified: 2009-02-17
There appears to be no way to get the anchor tag from the HttpServletRequest (see http://forum.java.sun.com/thread.jspa?forumID=45&threadID=404954). However, I know that data arrives at our servers because our apache logs show urls with the anchor tags.

So, apparently that information is just being dropped.

Is there any way to hack the system to allow me to see the anchor tag? For instance, is there a servlet engine that makes it available in some other way such that I could have a servlet filter that got the anchor using the alternate means and then put it into an attribute in the HttpServletRequest that I could use in my servlets?

Perhaps there is a way to install some sort of filter on port 80 that modifies incoming urls so that the anchor is turned into a parameter of the url so that I can access it using getParameter in the servlet?
Question by:HappyEngineer
  • 2
  • 2
LVL 92

Expert Comment

ID: 13657270
If the browser is not sending it then there is no way for the server to get it.

Author Comment

ID: 13657276
The browser is definitely sending it. It's in our apache logs.
LVL 92

Expert Comment

ID: 13657338
So have you tested the claims in the above post (which states it is *not* sent).
LVL 15

Accepted Solution

aozarov earned 1000 total points
ID: 13657388
I never tried to get anchor tags (but I am a bit surprise that it does not work).
A work around could be to send request via javaSrcript that will replace  the URL #xxxx with ?anchor=xxxx
LVL 15

Expert Comment

ID: 13657660
Are you sure this didn't work for you?
 StringBuffer urlBuffer = HttpUtils.getRequestURL(req);
     URL url = new URL(urlBuffer.toString());
     String anchor = url.getRef();

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

580 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