Exploration of URL redirection for the JSP server Resin

Source: Internet
Author: User

The simplest thing is to convert the URL Based on the URL rewriting (rewrite) module in various web servers:
In this way, the program implementation will be almost unchanged? The link id = 234 is mapped to news/234.html, and looks like a static link from the outside. On the Resin server, you can use web. xml of webinfo to set: the URL rewrite function is powerful enough to write a book.

When I need? When id = 234 is mapped to news/234.html, you only need to set the Web. XML in the directory where web-INF is located:

Add the following statement
<Filter-name = 'rewrite'
Filter-class = 'com. Caucho. Filters. rewritefilter'>
<Init>
<Rewrite pattern = "/(/d +)/. html" target = "// news. jsp /? Id = $1 "/>
// <Rewrite pattern = "/value _ (. +)/. html" target = "// news. jsp /? T = $1 "/> is set as another parameter.
</Init>
</Filter>

<Filter-mapping URL-pattern = '/*' filter-name = 'rewrite'/>

 

You can explore other methods by yourself. The rewrite function is very powerful.

After this configuration, you can access the original dynamic page through a link like 1234.htm.

There are also some benefits through URL rewrite:

  • Hiding background implementation: This is very useful for background application platform migration: when migrating from JSP to ASP, foreground users cannot feel the changes of background applications;
  • Simplified data validation: parameters such as (/d +) can effectively control the number format and even digits;

For example, we need to extract the application from news. jsp? Id = 234 migrate to news. php? When query is set to 234, the foreground performance can always be news/234.html. Separating the application from the foreground: This ensures the stability of the URL, while using mod_rewrite can even forward requests to other backend servers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.