0

I will put multiple related questions here I hope there is no problem with that.

I have JBoss server on my pc and I want to do the following:

when user clicks a link like ( www.abc.com/login ) I want to redirect him to ( www.abc.com/jsp/login.jsp) without showing the new URL.

The purpose of this is to hide folders and file extensions from users so they don't starting testing and messing with stuff.

So my questions about that are:

1) How to do it while keeping the (www.abc.com/login) on the user browser?

2) How to hide some of the url? like if the url is www.abc.com/jsp/login.jsp, how to hide the (.jsp) or changing the file/folder arrangement to show less information to users?

3) If I think in a wrong way and/or there is a better/easier way to do it then please advice me.

I found some related stuff like this but I didn't understand it because I have no knowledge in jboss and also a bit weak in english.

Thank you all, and sorry for the confusion.

Mehsen
  • 71
  • 1
  • 2
  • 10
  • 1
    create a folder `login`, create `index.jsp` in that, include `../js/login.jsp` in that jsp file? – Prasanth Oct 08 '12 at 06:17
  • But I have alot of jsp files. Yes it is a solution but If there is something else it will be better. – Mehsen Oct 08 '12 at 06:32

1 Answers1

3

You should always use Servlet in combinations with JSPs.

Servlets do act as a controllers in a web applications.

IMO, You should create a Servlet and map it with name like you login and then forward to a page. This achieves your goal to hide directory structures and keeps URL unchanged.

e.g.

<servlet>
        <servlet-name>LoginServlet</servlet-name>
        <servlet-class>com.test.controllers.LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/login</url-pattern>
</servlet-mapping>

Pass /login in action of your form.

In your Servlet after performing business logic. Forward to desired page

request.getRequestDispatcher("/jsp/login.jsp").forward(request, response);

You didn't mention your skills with Servlets. So, I would suggest to

Read more:

  1. https://stackoverflow.com/tags/servlets/info
  2. What is the difference between JSF, Servlet and JSP?
  3. http://pdf.coreservlets.com/Servlet-Basics.pdf
Community
  • 1
  • 1
Hardik Mishra
  • 14,779
  • 9
  • 61
  • 96
  • Thanks for the links, I have very little knowledge in `Servlets`, I just started learning it. I will test your solution and inform you. – Mehsen Oct 08 '12 at 07:29