You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steve Higham <st...@sjlt.co.uk> on 2012/09/30 18:22:13 UTC

How to pretty print HTML from Struts

My Struts Views are made up of JSP and Tiles and the resulting HTML is
untidy to say the least. This causes problems when I try to compare it with
HTML mock-ups. To solve this I'm trying to use the JTidy library to pretty
print the HTML output to the browser.

 

I'm using the JTidyFilter configured as follows: -

 

     <filter-mapping>

       <filter-name>StrutsFilter</filter-name>

       <url-pattern>/*</url-pattern>

     </filter-mapping>

  

     <filter-mapping>

       <filter-name>JTidyFilter</filter-name>

       <url-pattern>/*</url-pattern>

     </filter-mapping>

 

This seems to be failing because the Struts Filter Dispatchers only pass the
request down the Filter Chain if it is not a Struts Request (e.g. *.action).
Therefore this config will try to pretty-print *.css, *.js, *.img etc. but
completely ignores the outputs of my actions.

 

Does anyone know a sensible way of pretty printing the Struts HTML output to
the browser?

 

Many Thanks,

 

Steve

 

Steve Higham

 


Re: How to pretty print HTML from Struts

Posted by Lukasz Lenart <lu...@apache.org>.
2012/9/30 Steve Higham <st...@sjlt.co.uk>:
>> Does anyone know a sensible way of pretty printing the Struts HTML
>> output to the browser?

Which version of S2 ? Sometime ago all the tags' templates were
updated with FreeMarker trimming functionality, but if you have
problem with that please report an issue with JIRA.


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: How to pretty print HTML from Struts

Posted by Steve Higham <st...@sjlt.co.uk>.
Yes - I've got some complex tags and the resultant HTML has loads of
redundant whitespace in all the wrong places. Trying to compare with
original mock-ups takes for ever.

I like doing this with a filter because it's easy to remove if I'm having
problems later. I've just got it working and it's doing what I want. I
appreciate it may cause problems later...

The correct config is: -

	<filter-mapping>
	  <filter-name>JTidyFilter</filter-name>
	  <url-pattern>*.action</url-pattern>
	</filter-mapping>
	 
	<filter-mapping>
	  <filter-name>StrutsFilter</filter-name>
	  <url-pattern>/*</url-pattern>
	</filter-mapping>

It was just the ordering of the filters that was causing problems.

Is there a better way of tidying up the HTML being emitted from a Struts
View?

Kind Regards,

Steve


-----Original Message-----
From: Dave Newton [mailto:davelnewton@gmail.com] 
Sent: 30 September 2012 18:05
To: Struts Users Mailing List
Subject: Re: How to pretty print HTML from Struts

Ugh. IMO relying on textual representation of a DOM is fragile and broken,
especially if you're unable to ignore whitespace-is there a reason you're
doing it like this?

Dave

(pardon brevity, typos, and top-quoting; on cell) On Sep 30, 2012 12:22 PM,
"Steve Higham" <st...@sjlt.co.uk> wrote:

> My Struts Views are made up of JSP and Tiles and the resulting HTML is 
> untidy to say the least. This causes problems when I try to compare it 
> with HTML mock-ups. To solve this I'm trying to use the JTidy library 
> to pretty print the HTML output to the browser.
>
>
>
> I'm using the JTidyFilter configured as follows: -
>
>
>
>      <filter-mapping>
>
>        <filter-name>StrutsFilter</filter-name>
>
>        <url-pattern>/*</url-pattern>
>
>      </filter-mapping>
>
>
>
>      <filter-mapping>
>
>        <filter-name>JTidyFilter</filter-name>
>
>        <url-pattern>/*</url-pattern>
>
>      </filter-mapping>
>
>
>
> This seems to be failing because the Struts Filter Dispatchers only 
> pass the request down the Filter Chain if it is not a Struts Request 
> (e.g.
> *.action).
> Therefore this config will try to pretty-print *.css, *.js, *.img etc. 
> but completely ignores the outputs of my actions.
>
>
>
> Does anyone know a sensible way of pretty printing the Struts HTML 
> output to the browser?
>
>
>
> Many Thanks,
>
>
>
> Steve
>
>
>
> Steve Higham
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to pretty print HTML from Struts

Posted by Dave Newton <da...@gmail.com>.
Ugh. IMO relying on textual representation of a DOM is fragile and broken,
especially if you're unable to ignore whitespace-is there a reason you're
doing it like this?

Dave

(pardon brevity, typos, and top-quoting; on cell)
On Sep 30, 2012 12:22 PM, "Steve Higham" <st...@sjlt.co.uk> wrote:

> My Struts Views are made up of JSP and Tiles and the resulting HTML is
> untidy to say the least. This causes problems when I try to compare it with
> HTML mock-ups. To solve this I'm trying to use the JTidy library to pretty
> print the HTML output to the browser.
>
>
>
> I'm using the JTidyFilter configured as follows: -
>
>
>
>      <filter-mapping>
>
>        <filter-name>StrutsFilter</filter-name>
>
>        <url-pattern>/*</url-pattern>
>
>      </filter-mapping>
>
>
>
>      <filter-mapping>
>
>        <filter-name>JTidyFilter</filter-name>
>
>        <url-pattern>/*</url-pattern>
>
>      </filter-mapping>
>
>
>
> This seems to be failing because the Struts Filter Dispatchers only pass
> the
> request down the Filter Chain if it is not a Struts Request (e.g.
> *.action).
> Therefore this config will try to pretty-print *.css, *.js, *.img etc. but
> completely ignores the outputs of my actions.
>
>
>
> Does anyone know a sensible way of pretty printing the Struts HTML output
> to
> the browser?
>
>
>
> Many Thanks,
>
>
>
> Steve
>
>
>
> Steve Higham
>
>
>
>