wood burning stoves 2.0*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
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 ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60782
        
      65

    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.


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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?

     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: trim-directive-whitespaces - Seriously has anyone gotten this to work?
     
    Similar Threads
    scripting-invalid tag
    isELIgnored="false"
    Unable to get the login.jsp to fire from example of book "Java EE 5 Development with NetBeans 6"
    SCRIPTING-INVALID declaration
    context root