0

I'm developing small web application to give access to a URL for authorised users.

After validating the URL, I'm providing the two hyperlinks like Reports and Logout. This is the code.

<a href ="http://hostname.com/reports/users">Reports</a>
<a href="LogoutServlet">Logout</a>

Here the question is the time user click on Reports link, its giving the href link as it is in web browser like http://hostname.com/reports/users Expected output should be like http://hostname.com/Somethingelse

Update Question:

To hide real folder path i.e http://hostname.com/reports/users am using .htaccess. I have kept this file under WEB-INF folder, can anyone please hep me how to form RewriteRule and RewriteCond in .htaccess file. This is the file I have tried. If .htaccess is invoking and if it is wrong how come still its going to same folder the time I click on Reports link. This is the .htaccess I have tried

RewriteEngine On
RewriteCond %{HTTP_HOST} ([^\.]+).hostname.com [NC]
RewriteRule ^.*$ http://hostname.com/reports/users [L]
JSP
  • 447
  • 2
  • 8
  • 21
  • you can do it with .htaccess https://stackoverflow.com/questions/14070635/rewriting-url-to-hide-real-page-path – bill.gates Apr 27 '19 at 14:17
  • Thanks for comment @Ifaruki, .htaccess is a third party library. Is it possible to do the same within html? – JSP Apr 27 '19 at 14:22

1 Answers1

0

This way you can customize the servlet mapping pattern

@WebServlet("/reports/users")
public class LogoutServlet extends HttpServlet {
//
}

See https://docs.oracle.com/javaee/6/api/javax/servlet/annotation/WebServlet.html

admlz635
  • 1,001
  • 1
  • 9
  • 18