Matt RaibleMatt Raible is a Java Champion and Developer Advocate at Okta. developer.okta.com

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Prettying up JSPWiki's URLs

Recently, AppFuse user Charlse Li sent me an e-mail with a "PostfixURLConstructor" class designed to pretty up JSPWiki's URL. With the patch he sent, I was able to change URLs from /wiki/Wiki.jsp?page=AppFuse to /wiki/AppFuse.html. Applying the patch was quite easy, but maintaining backwards compatibility and security required a little more work. Below are the steps I went through to get everything working properly:

  • Download postfixurlconstructor.zip and extract to your hard-drive. Copy the "com" directory to your wiki/WEB-INF/classes directory.
  • Change the <url-pattern> of the WikiServlet in web.xml from /wiki/* to *.html.
  • Add the following two lines to your WEB-INF/jspwiki.properties file:

    jspwiki.urlConstructor = PostfixURLConstructor
    jspwiki.PostfixURLConstructor.postfix = .html

This is all you need to do to change the default URL schema. However, if you're like me and you've had a JSPWiki instance setup for awhile, you'll need to maintain backwards-compatibility. I wanted to make sure the old URLs mapped to the new ones. In addition, the "edit URL" changed from Edit.jsp?page=PageName to pageName.html?do=Edit. Since web.xml and <security-constraint> can't contain regular expressions, I used the ultra-cool UrlRewriteFilter to solve both issues. Here's the steps I went through to configure it properly:

  • Download UrlRewriteFilter 2.5.1 and extract the JAR to your WEB-INF/lib directory.
  • Change your web.xml to use a 2.3 DTD instead of a 2.2 DTD and add the filter and filter-mapping to web.xml.
  • Create a WEB-INF/urlrewrite.xml file with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<!DOCENGINE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.5//EN"
    "http://tuckey.org/res/dtds/urlrewrite2.5.dtd">

<urlrewrite>
    <rule>
        <from>^/Wiki.jsp\?page=(.*)$</from>
        <to type="redirect">$1.html</to>
    </rule>

    <rule>
        <from>^/(.*).html\?do=Edit$</from>
        <to type="redirect">Edit.jsp?page=$1</to>
    </rule>
</urlrewrite>

That's it - restart your server and you should be good to go. Thanks for the patch and instructions Charlse!

Update: There does seem to be a couple of issues. The 1st is that none of the attachments are resolving correctly (example). The 2nd that when I try to edit a page, it always shows up with the Main page's text. I'm not going to back out the change just yet, but I will if I can't fix it in the next several hours.

Update 2: I ended up backing out this change, but left in a forward from *.html to Wiki.jsp?page=$1 so all URLs in this post should still work. The "not being able to edit" was the major reason I rolled back to the old URL schema. The attachment issue seems to be related to my browser's cache. Clearing it fixed the problem.

Posted in Java at Aug 21 2005, 03:01:59 PM MDT 1 Comment
Comments:

I used it for my new site. It's very usefull.

Posted by David on December 09, 2005 at 01:47 PM MST #

Post a Comment:
  • HTML Syntax: Allowed