You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by rickchev <ri...@flash.net> on 2003/11/11 20:54:51 UTC

TSVParser utility

All,

I have a need parse a TSV file and generate a name/value pair of the file
contents.  In searching the web I found the turbine TSVParser utility class.
If I just want to utilize the class, how should I go about it? Is
downloading the entire turbine.jar too much to utilize just the one class or
is there a better way?

Thanks for any advice.  

Rick Chevalier
 


RE: forcing expiration question

Posted by Eric Pugh <ep...@upstate.com>.
Why don't you submit a patch?  I am trying to share the knowledge of
turbine!  A patch and a unit test would be great...  I think though the way
in 2.3 and forward is to do these things in the .vm template, not sure
though..

Eric

> -----Original Message-----
> From: Jeff Painter [mailto:painter@kiasoft.com]
> Sent: Wednesday, November 12, 2003 8:34 PM
> To: Turbine Users List
> Subject: RE: forcing expiration question
>
>
>
>
> I think I found a problem with HttpUtils in
>
> 	org.apache.turbine.util.HttpUtils
>
> [Wed Nov 12 14:27:30 EST 2003] -- DEBUG --  DateManip: Mon
> Nov 10 14:27:30 EST 2003
> [Wed Nov 12 14:27:30 EST 2003] -- DEBUG --  HttpUtils: Mon,
> 10 Nov 02003 19:27:30 GMT
>
> it looked like it was placing an extra zero in front of my year and
> looking at the code in cvs it looks like they httpDateFormat
> has an extra
> "y" in the year portion that is causing me my troubles.
>
> if someone can fix this in cvs that would be cool :)
>
>
> public class HttpUtils
> {
>     /**
>      * The date format to use for HTTP Dates.
>      */
>     private static SimpleDateFormat httpDateFormat;
>
>     static
>     {
>         httpDateFormat = new SimpleDateFormat(
>                 "EEE, dd MMM yyyyy HH:mm:ss z", Locale.US);
> 			     ^^^^^ -> 5 digit year?
>
>         httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
>     }
>
>
>
>
> --
> Regards,
>
> Jeffery Painter
>
> - --
> painter@kiasoft.com                     http://kiasoft.com
> PGP FP: 9CE8 83A2 33FA 32B1 0AB1  4E62 E4CB E4DA 5913 EFBC
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iD8DBQE/qEQE5Mvk2lkT77wRAnMJAJ9vJ6qOkg/mvqqIpz7troCEQJ8bFACglu/U
> YNXabx7DZOV2Hd9LwSTmGpY=
> =dWiu
> -----END PGP SIGNATURE-----
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


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


RE: forcing expiration question

Posted by Jeff Painter <pa...@kiasoft.com>.
I made a quick modification on my own HttpUtils to correct the year 
problem for now. I see that this class is being deprecated for 2.3 anyway.

For mozilla 1.5 to be happy I read through their web standards on page 
expiration to determine what is deemed to be correct expiration headers 
and found the following code to work (DateManip is my own date class)
hopefully it works as well in IE although I'm not sure how to determine 
that exactly...


	doPostBuildTemplate( Rundata data, Context context )
	{
        	// expire in 60 seconds
        	DateManip dm = new DateManip();
        	dm.addMinutes( 1 );

        	// Pragma is considered an invalid header according to RFC 2616
		// data.getResponse().setHeader("Pragma", "no-cache");

        	data.getResponse().setHeader("Last-modified", HttpUtils.formatHttpDate( new Date() ) );
        	data.getResponse().setHeader("Expires", HttpUtils.formatHttpDate( dm.getDate() ) );
        	data.getResponse().setHeader("Cache-Control", "private,max-age=60");
	}

aparently mozilla does some computation on the last-modified header and 
max-age to determine a valid expiration. expires is supposed to work on 
it's own but it seemed to not want to work for me. max-age value is in 
seconds.

hope this helps anyone else looking for some cache control :)

	Regards,

	Jeff Painter



On Wed, 12 Nov 2003, Jeff Painter wrote:

> 
> I think I found a problem with HttpUtils in 
> 
> 	org.apache.turbine.util.HttpUtils
> 
> [Wed Nov 12 14:27:30 EST 2003] -- DEBUG --  DateManip: Mon Nov 10 14:27:30 EST 2003
> [Wed Nov 12 14:27:30 EST 2003] -- DEBUG --  HttpUtils: Mon, 10 Nov 02003 19:27:30 GMT
> 
> it looked like it was placing an extra zero in front of my year and 
> looking at the code in cvs it looks like they httpDateFormat has an extra 
> "y" in the year portion that is causing me my troubles.
> 
> if someone can fix this in cvs that would be cool :)
> 
> 
> public class HttpUtils
> {
>     /**
>      * The date format to use for HTTP Dates.
>      */
>     private static SimpleDateFormat httpDateFormat;
> 
>     static
>     {
>         httpDateFormat = new SimpleDateFormat(
>                 "EEE, dd MMM yyyyy HH:mm:ss z", Locale.US);
> 			     ^^^^^ -> 5 digit year?
> 
>         httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
>     }



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


RE: forcing expiration question

Posted by Jeff Painter <pa...@kiasoft.com>.

I think I found a problem with HttpUtils in 

	org.apache.turbine.util.HttpUtils

[Wed Nov 12 14:27:30 EST 2003] -- DEBUG --  DateManip: Mon Nov 10 14:27:30 EST 2003
[Wed Nov 12 14:27:30 EST 2003] -- DEBUG --  HttpUtils: Mon, 10 Nov 02003 19:27:30 GMT

it looked like it was placing an extra zero in front of my year and 
looking at the code in cvs it looks like they httpDateFormat has an extra 
"y" in the year portion that is causing me my troubles.

if someone can fix this in cvs that would be cool :)


public class HttpUtils
{
    /**
     * The date format to use for HTTP Dates.
     */
    private static SimpleDateFormat httpDateFormat;

    static
    {
        httpDateFormat = new SimpleDateFormat(
                "EEE, dd MMM yyyyy HH:mm:ss z", Locale.US);
			     ^^^^^ -> 5 digit year?

        httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    }




-- 
Regards,

Jeffery Painter

- --
painter@kiasoft.com                     http://kiasoft.com
PGP FP: 9CE8 83A2 33FA 32B1 0AB1  4E62 E4CB E4DA 5913 EFBC

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
 
iD8DBQE/qEQE5Mvk2lkT77wRAnMJAJ9vJ6qOkg/mvqqIpz7troCEQJ8bFACglu/U
YNXabx7DZOV2Hd9LwSTmGpY=
=dWiu
-----END PGP SIGNATURE-----


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


RE: forcing expiration question

Posted by Jeff Painter <pa...@kiasoft.com>.
On Thu, 13 Nov 2003, Greg Kerdemelidis wrote:

> 
> Hmm. I had lots of problems with cache expiration and form submits with an
> earlier version of Moz. Essentially, it totally ignored my cache pragma
> directives, but there's no need to get into that right now...
> 
> It seems the major difference between your two headers is the actual time of
> the expiration -- maybe Mozilla just ignores dates from 1969?
> 
> You could set the expiration time to be Now + 2 seconds, which would
> essentially invalidate the cached copy by the time it gets served and
> rendered.
> 
> Also, it appears that max-age: shouldn't be a header in its own right, but a
> part of the Cache-control header.
> 
> Good luck.
> 
> -Greg
> 

I think you are right about max-age.. I found some code from macromedia 
that used the setDateHeader for max-age which now I think is incorrect 
(don't trust all the code you find on the web ;P )

I'll play with the date some more and see if I can find the correct 
answer.

This was using mozilla 1.5 btw.


-- 
Regards,

Jeffery Painter



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


RE: forcing expiration question

Posted by Greg Kerdemelidis <gk...@snap.net.nz>.
Hmm. I had lots of problems with cache expiration and form submits with an
earlier version of Moz. Essentially, it totally ignored my cache pragma
directives, but there's no need to get into that right now...

It seems the major difference between your two headers is the actual time of
the expiration -- maybe Mozilla just ignores dates from 1969?

You could set the expiration time to be Now + 2 seconds, which would
essentially invalidate the cached copy by the time it gets served and
rendered.

Also, it appears that max-age: shouldn't be a header in its own right, but a
part of the Cache-control header.

Good luck.

-Greg

> -----Original Message-----
> From: Jeff Painter [mailto:painter@kiasoft.com]
> Sent: Thursday, 13 November 2003 7:30 a.m.
> To: Turbine Users List
> Subject: forcing expiration question
> 
> 
> I have setup my screens to call doPostBuildTemplate() in which I force the
> expiration of pages as such
> 
>   doPostBuildTemplate( Rundata data, Context context )
>   {
> 
>     data.getResponse().setHeader("Cache-Control", "no-store");
>     data.getResponse().setHeader("Pragma", "no-cache");
>     data.getResponse().setDateHeader("max-age", 0);
> 
>     // I tried 0 as well for expires and did not help
>     data.getResponse().setDateHeader("Expires", -1);
> 
>   }
> 
> 
> I verified with org.apache.axis.utils.tcpmon the header data is coming
> through from turbine
> 
> my apps header info
> 
> HTTP/1.1 200 OK
> Date: Wed, 12 Nov 2003 18:19:31 GMT
> Server: Apache/2.0.40 (Red Hat Linux)
> Expires: Wed, 31 Dec 1969 23:59:59 GMT
> Content-Language: en-US
> Pragma: no-cache
> max-age: Thu, 01 Jan 1970 00:00:00 GMT
> Cache-Control: no-store
> Connection: close
> Transfer-Encoding: chunked
> Content-Type: text/html;charset=ISO-8859-1
> 
> 
> and so I think all looks fine, but using mozilla "Page Info" it says
> Expires: Not Specified
> 
> 
> I pulled up another website (cnn.com) to test against
> 
> their header looks like
> 
> HTTP/1.1 200 OK
> Server: Netscape-Enterprise/6.1 AOL
> Date: Wed, 12 Nov 2003 18:14:41 GMT
> Last-modified: Wed, 12 Nov 2003 18:14:36 GMT
> Expires: Wed, 12 Nov 2003 18:15:36 GMT
> Cache-control: private,max-age=60
> Content-type: text/html
> Transfer-Encoding: chunked
> 
> and in mozilla page info gives their expiration date correctly.
> 
> 
> Any clues as to what I'm doing wrong or is something wrong with mozilla?
> 
> 
> --
> Regards,
> 
> Jeffery Painter
> 
> - --
> painter@kiasoft.com                     http://kiasoft.com
> PGP FP: 9CE8 83A2 33FA 32B1 0AB1  4E62 E4CB E4DA 5913 EFBC
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> 
> iD8DBQE/qEQE5Mvk2lkT77wRAnMJAJ9vJ6qOkg/mvqqIpz7troCEQJ8bFACglu/U
> YNXabx7DZOV2Hd9LwSTmGpY=
> =dWiu
> -----END PGP SIGNATURE-----
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org



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


forcing expiration question

Posted by Jeff Painter <pa...@kiasoft.com>.
I have setup my screens to call doPostBuildTemplate() in which I force the 
expiration of pages as such

  doPostBuildTemplate( Rundata data, Context context )
  {

    data.getResponse().setHeader("Cache-Control", "no-store");
    data.getResponse().setHeader("Pragma", "no-cache");
    data.getResponse().setDateHeader("max-age", 0);

    // I tried 0 as well for expires and did not help
    data.getResponse().setDateHeader("Expires", -1);  

  }


I verified with org.apache.axis.utils.tcpmon the header data is coming 
through from turbine

my apps header info

HTTP/1.1 200 OK
Date: Wed, 12 Nov 2003 18:19:31 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Expires: Wed, 31 Dec 1969 23:59:59 GMT
Content-Language: en-US
Pragma: no-cache
max-age: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-store
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html;charset=ISO-8859-1


and so I think all looks fine, but using mozilla "Page Info" it says 
Expires: Not Specified


I pulled up another website (cnn.com) to test against

their header looks like

HTTP/1.1 200 OK
Server: Netscape-Enterprise/6.1 AOL
Date: Wed, 12 Nov 2003 18:14:41 GMT
Last-modified: Wed, 12 Nov 2003 18:14:36 GMT
Expires: Wed, 12 Nov 2003 18:15:36 GMT
Cache-control: private,max-age=60
Content-type: text/html
Transfer-Encoding: chunked

and in mozilla page info gives their expiration date correctly.


Any clues as to what I'm doing wrong or is something wrong with mozilla?


-- 
Regards,

Jeffery Painter

- --
painter@kiasoft.com                     http://kiasoft.com
PGP FP: 9CE8 83A2 33FA 32B1 0AB1  4E62 E4CB E4DA 5913 EFBC

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
 
iD8DBQE/qEQE5Mvk2lkT77wRAnMJAJ9vJ6qOkg/mvqqIpz7troCEQJ8bFACglu/U
YNXabx7DZOV2Hd9LwSTmGpY=
=dWiu
-----END PGP SIGNATURE-----


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


RE: TSVParser utility

Posted by Jeff Painter <pa...@kiasoft.com>.
You could use my code which works independently of turbine and use the 
.changeDelemiter("\t") method on the parser. That should be all there is 
to it.

Jeff Painter


On Wed, 12 Nov 2003, Greg Kerdemelidis wrote:

> 
> I guess, you've got two options:
> 
> 1) You could hack the recent CSV parser from Jeff Painter which returns
> key/value pairs, and use '\t' instead of ','.
> 
> 2) You could use the recent StrictParser that I submitted, subclass the
> sucker and roll a Map into it. Initialise with StrictParser(string,'\t') (
> read: super(arg,'\t') ) instead of StrictParser(string,',').
> 
> 3) Introduce a third alternative that makes everybody magically happy.
> 
> In essence a TSV is a '\t' instead of a ',' correct?
> 
> As should be obvious already, depending on your requirements one of the
> approaches will work better than the other. 
> 
> -Greg
> 
> > -----Original Message-----
> > From: rickchev [mailto:rickchev@flash.net]
> > Sent: Wednesday, 12 November 2003 8:55 a.m.
> > To: turbine-user@jakarta.apache.org
> > Subject: TSVParser utility
> > 
> > All,
> > 
> > I have a need parse a TSV file and generate a name/value pair of the file
> > contents.  In searching the web I found the turbine TSVParser utility
> > class.
> > If I just want to utilize the class, how should I go about it? Is
> > downloading the entire turbine.jar too much to utilize just the one class
> > or
> > is there a better way?
> > 
> > Thanks for any advice.
> > 
> > Rick Chevalier



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


RE: TSVParser utility

Posted by Greg Kerdemelidis <gk...@snap.net.nz>.
I guess, you've got two options:

1) You could hack the recent CSV parser from Jeff Painter which returns
key/value pairs, and use '\t' instead of ','.

2) You could use the recent StrictParser that I submitted, subclass the
sucker and roll a Map into it. Initialise with StrictParser(string,'\t') (
read: super(arg,'\t') ) instead of StrictParser(string,',').

3) Introduce a third alternative that makes everybody magically happy.

In essence a TSV is a '\t' instead of a ',' correct?

As should be obvious already, depending on your requirements one of the
approaches will work better than the other. 

-Greg

> -----Original Message-----
> From: rickchev [mailto:rickchev@flash.net]
> Sent: Wednesday, 12 November 2003 8:55 a.m.
> To: turbine-user@jakarta.apache.org
> Subject: TSVParser utility
> 
> All,
> 
> I have a need parse a TSV file and generate a name/value pair of the file
> contents.  In searching the web I found the turbine TSVParser utility
> class.
> If I just want to utilize the class, how should I go about it? Is
> downloading the entire turbine.jar too much to utilize just the one class
> or
> is there a better way?
> 
> Thanks for any advice.
> 
> Rick Chevalier
> 



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