Question

I use .htaccess file for url rewritting.To enable .htaccess file I put the urlrewritefilter-4.0.3.jar file inside WEB-INF\lib\ and inside web.xml I have added the following code.

   <filter>
      <filter-name>UrlRewriteFilter</filter-name>
          <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>

defaults to false. use mod_rewrite style configuration file (if this is true and confPath is not specified confPath will be set to /WEB-INF/.htaccess)

   <init-param>
       <param-name>modRewriteConf</param-name>
       <param-value>true</param-value>
   </init-param>
   </filter>
   <filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
   </filter-mapping>`

My .htacces file code is

    RewriteRule ^/()$ index.jsp [NC,L]
    RewriteRule ^/login/?$ login.jsp [NC,L] #Handle requests for "login"
    RewriteRule ^/logout/?$ login.jsp [NC,L] #Handle requests for "login"
    RewriteRule ^/contact_us/?$ contact.jsp [NC,L] #Handle requests for "contactus"
    RewriteRule ^([/A-Za-z0-9_]+)$ user.jsp [NC,L]
    RewriteRule ^([/A-Za-z0-9_]+)/$ user.jsp [NC,L]

I have one user.jsp file. I used regular expression for url maping so that what ever i type in url it open the user.jsp file. I want to access the actual url typed inside the user.jsp file. Suppose I type http://localhost:8080/project/abhiramgiri. I used

  <%
       String getURL=request.getRequestURI();
       out.print(getURL);
  %>

It shows the path to the file as http://localhost:8080/project/user.jsp Actually I need http://localhost:8080/project/abhiramgiri. It does not show the actual typed url. It retrieve the original path. Please, Help me for this problem.

Was it helpful?

Solution

What is it the URL that shows the web browser? depending on your application you could use JavaScript to get the URL using document.URL (see get-current-url-with-javascript ) You must regard security.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top