IntelliJ Java IDE
The moose likes JSP and the fly likes trim-directive-whitespaces - Seriously has anyone gotten this to work? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "trim-directive-whitespaces - Seriously has anyone gotten this to work?" Watch "trim-directive-whitespaces - Seriously has anyone gotten this to work?" New topic
Author

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

jeff kies
Greenhorn

Joined: Feb 07, 2002
Posts: 5
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 opinionated walrus
    Marshal

    Joined: Jan 10, 2002
    Posts: 50691

    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.


    [Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
    jeff kies
    Greenhorn

    Joined: Feb 07, 2002
    Posts: 5
    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?

     
     
    subject: trim-directive-whitespaces - Seriously has anyone gotten this to work?
     
    Threads others viewed
    Unable to get the login.jsp to fire from example of book "Java EE 5 Development with NetBeans 6"
    SCRIPTING-INVALID declaration
    isELIgnored="false"
    scripting-invalid tag
    context root
    developer file tools

    cast iron skillet 49er

    more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture