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.

4

1 回答 1

3

您应该始终将 Servlet 与 JSP 结合使用。

Servlets在 Web 应用程序中充当控制器。

IMO,您应该创建一个 Servlet 并将其映射为您的名称login,然后转发到一个页面。这实现了隐藏目录结构并保持 URL 不变的目标。

例如

<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>

传入你/login的.actionform

在您的 Servlet 中执行业务逻辑之后。转发到所需页面

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

您没有提到您在 Servlet 方面的技能。所以,我建议

阅读更多:

  1. https://stackoverflow.com/tags/servlets/info
  2. JSF、Servlet 和 JSP 有什么区别?
  3. http://pdf.coreservlets.com/Servlet-Basics.pdf
于 2012-10-08T07:07:04.710 回答