Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trim-directive-whitespaces - Seriously has anyone gotten this to work?

 
jeff kies
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to prevent jsp directives from inserting blank lines into the markup. I found some great info here:

http://stackoverflow.com/questions/208736/strip-whitespace-from-jsp-output

This article lists two ways to do this:
  • use a page directive
  • add a setting to web.xml


  • The page directive does the job, but it stinks that I have to go in and put that on every jsp I have. That's just inefficient.

    The other way to do this is preferable, which is just adding this setting to web.xml:



    ..but I can NOT for the life of me get this to work.

    My jsp and servlet version should support this; I'm running the following:
  • Server info: Apache Tomcat/7.0.19
  • Servlet version: 3.0
  • JSP version: 2.1
  • Java version: 1.6.0_29


  • Has anyone been able to get the web.xml solution for this to work?

    Thanks
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 65229
    95
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I've never tried using it as I've never worried about the extra whitespace. But one reason might be that your URL pattern isn't matching your requests.

    If you are following best practices and using servlet page controllers that forwards to the JSPs, the URL will be that of the controller and not one that ends with .jsp.

    If you are addressing the JSPs directly however, I got nothing.
     
    jeff kies
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    great suggestion - but no luck.

    I changed the url-pattern to:

    [code]
    <url-pattern>*.action</url-pattern>
    [\code]

    but it still didn't work. really good ide though.

    anyone else out there come across this?

     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic