Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 830049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:58:51+00:00 2026-05-15T03:58:51+00:00

I’m developing a Grails web application (mainly as a learning exercise). I have previously

  • 0

I’m developing a Grails web application (mainly as a learning exercise). I have previously written some standard Grails apps, but in this case I wanted to try creating a controller that would intercept all requests (including static html) of the form:

<a href="/testApp/testJsp.jsp">test 1</a>
<a href="/testApp/testGsp.gsp">test 2</a>   
<a href="/testApp/testHtm.htm">test 3</a>
<a href="/testApp/testHtml.html">test 4</a> 

The intent is to do some simple business logic (auditing) each time a user clicks a link. I know I could do this using a Filter (or a range of other methods), however I thought this should work too and wanted to do this using a Grails framework.

I set up the Grail UrlMappings.groovy file to map all URLs of that form (/$myPathParam?) to a single controller:

class UrlMappings {
    static mappings = {
      "/$controller/$action?/$id?"{
          constraints {
          }
      }
      "/$path?" (controller: 'auditRecord', action: 'showPage')
      "500"(view:'/error')
    }
}

In that controller (in the appropriate “showPage” action) I’ve been printing out the path information, for example:

def showPage = {        
    println "params.path = " + params.path
    ...
    render(view: resultingView)
}

The results of the println in the showPage action for each of my four links are

testJsp.jsp
testGsp.gsp
testHtm.htm
testHtml

Why is the last one “testHtml”, not “testHtml.html”?

In a previous (Stack Overflow query) Olexandr encountered this issue and was advised to simply concatenate the value of request.format – which, indeed, does return “html”. However request.format also returns “html” for all four links.

I’m interested in gaining an understanding of what Grails is doing and why. Is there some way to configure Grails so the params.path variable in the controller shows “testHtml.html” rather than stripping off the “html” extension? It doesn’t seem to remove the extension for any other file type (including .htm). Is there a good reason it’s doing this? I know that it is a bit unusual to use a controller for static html, but still would like to understand what’s going on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:58:52+00:00Added an answer on May 15, 2026 at 3:58 am

    This is related to content negotiation, which you can read about in section 6.8 of the Grails user guide. If Grails recognises the extension as a particular type, the extension is removed from the URL and the type is added to the “format” parameter.

    You can disable this behaviour by adding this entry to grails-app/conf/Config.groovy:

    grails.mime.file.extensions = false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 474k
  • Answers 474k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer We ended up using the Oracle Data Provider for .NET… May 16, 2026 at 4:08 am
  • Editorial Team
    Editorial Team added an answer From the help-file for the boot function: In all other… May 16, 2026 at 4:08 am
  • Editorial Team
    Editorial Team added an answer JSLint and a live demo site JSFiddle will give you… May 16, 2026 at 4:08 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.