Re: c:import doesn't work right with HEAD requests

2005-12-20 Thread erh
 Hassan Schroeder [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
  No. But I wouldn't have *any* expectations of an ambiguous situation.
  Out of curiousity, have you tried this with any different containers
  (Jetty, Resin, JRun, ...)?

no, I haven't.  I think I've got a websphere instance I can get to.
I'll try it there.  That might have a different implementation of the
core taglibs even .

On Sun, Dec 18, 2005 at 05:08:54PM -0800, Bill Barker wrote:
 From http://issues.apache.org/bugzilla/show_bug.cgi?id=37466, it looks like 
 it's a waste of time checking other containers.  It seems that this is a 
 known bug at least in the Jakarta implementation of JSTL.
known? ha!  I submitted that, and judging by the response I got when
asking about this problem on the taglibs list, I wouldn't be surprised if
you're the first other person to see that bug. :-|

eric

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: c:import doesn't work right with HEAD requests

2005-12-18 Thread erh
On Sun, Dec 18, 2005 at 09:06:22AM -0500, Martin Gainty wrote:
 Did you include the core taglib spec before using 'c' reference identifier
 %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; %
Of course.  It's the very first line in testit.jsp.  w/o that it
wouldn't work even for GET requests.

 What does the Tomcat log say about this?
The only output in the log is what I wrote there with 
System.out.println.

eric

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: c:import doesn't work right with HEAD requests

2005-12-18 Thread Martin Gainty
Eric-
the examples dont indicate how the leading slash can work without the URL 
specification (in this case URL spec for file)
did you try 
c:import url=file://textit.txt
Martin-
- Original Message - 
From: [EMAIL PROTECTED]
To: users@tomcat.apache.org
Sent: Sunday, December 18, 2005 12:40 AM
Subject: c:import doesn't work right with HEAD requests


 
 I'm having some trouble getting the c:import tag to work right.
 It seems to be perfectly fine when the request that tomcat receives is
 a GET request.  However, when it receives a HEAD request instead, c:import
 never actually reads the data.
 Is this a known bug?  Is it fixed in a more recent version of tomcat?
 I'm using 5.0.30.
 
 eric
 
 Here's an example jsp file testit.jsp:
 ---cut---
 %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
 c:import url=/testit.txt var=foo/
 %
System.out.println(FOO:[ + pageContext.getAttribute(foo) + ]);
 %
 worked: ${foo}
 ---cut---
 
 Here's testit.txt:
 ---cut---
 data data data
 ---cut---
 
 When I send a GET request to retrieve /myapp/testit.jsp, I get the expected
 worked: data data data in the response, and in catalina.out I get:
 ---cut---
 FOO:[data data data
 ]
 ---cut---
 That's what I expect.  However, if I send a HEAD request I get no output
 other than headers in the response (as I expect), but catalina.out has
 this instead:
 ---cut---
 FOO:[]
 ---cut---
 Notice there's nothing inside the [].
 
 Here's my HEAD request transcript:
 
 poe: {50} telnet localhost 8080
 Trying 127.0.0.1...
 Connected to localhost.
 Escape character is '^]'.
 HEAD /myapp/testit.jsp HTTP/1.1
 Host: localhost:8080
 
 HTTP/1.1 200 OK
 Set-Cookie: JSESSIONID=5A2DA89DDC03A24F4CF110EFD1BB6541; Path=/myapp
 Content-Type: text/html;charset=ISO-8859-1
 Content-Length: 15
 Date: Sun, 18 Dec 2005 05:29:54 GMT
 Server: Apache-Coyote/1.1
 
 ^]
 telnet c
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: c:import doesn't work right with HEAD requests

2005-12-18 Thread Bill Barker

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Sun, Dec 18, 2005 at 12:26:07PM -0800, Hassan Schroeder wrote:

 My guess is that tomcat uses a HEAD request to retrieve content with
 c:import if the request for the jsp page containing the c:import was
 requested with a HEAD request.  I'm not familiar enough with the tomcat
 code to easily figure out whether this is actually the case or not.

Actually, it JSTL rather than Tomcat, but you're basically correct, that is 
what is happening.  It could be fixed in c:import (to wrap the Request, and 
report GET for HEAD), but that is outside of Tomcat.

 If that's really what's happening, then I think it's wrong.  When a HEAD
 request is received, the jsp page should either:
 1) run exactly the same as if a GET request was received

This is outside of Tomcat's control, since any Servlet is free to override 
doHead to do anything it wants ;-).  In fact, this is one work-around for 
your problem:  Use extends=com.myfirm.mypackage.MyJSPPage, and implement 
doHead there.

 1a) unless the jsp page _explicitly_ checks the request method
 with ${request.method} or equivalent.

Checking this is probably the easiest work-around.  It's very unlikely that 
Tomcat could do it relyably.

 2) not run at all

That would violate the spec.

 eric 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: c:import doesn't work right with HEAD requests

2005-12-18 Thread Bill Barker

Hassan Schroeder [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:

 I really couldn't care less whether the content-length header is
 different.  The important thing here is what is in the logs.

 No, it's not; the important thing is whether there's any applicable
 spec that (even indirectly) requires the container to generate the
 exact same response body (to be discarded rather than returned) for
 a HEAD request as for a GET.


The Servlet spec and the HTTP/1.1 RFC have a slight disagreement here:  For 
a Servlet that doesn't implement doHead, and doesn't set contentLength in 
it's doGet method, a HEAD request will send back a 'Content-Length' header 
and no 'Transfer-Encoding' header.  A GET request (unless the content is 
very small, at least on Tomcat) will send back no 'Content-Length' header, 
and a 'Transfer-Encoding: chunked' header.

 When you tested it, do you get a FOO:[...] line in your logs (that
 corresponds to the HEAD request)?
 Does it have something between the '[' and ']'?

 No. But I wouldn't have *any* expectations of an ambiguous situation.
 Out of curiousity, have you tried this with any different containers
 (Jetty, Resin, JRun, ...)?


From http://issues.apache.org/bugzilla/show_bug.cgi?id=37466, it looks like 
it's a waste of time checking other containers.  It seems that this is a 
known bug at least in the Jakarta implementation of JSTL.


 The problem is that I _am_ getting a line like that, which implies
 that tomcat runs the jsp page, but there is nothing between the brackets.
 You can't see in the test case that I sent, but this causes all sorts of
 problems if you have code that tries to use the data that c:import
 supposedly loads.

 It sounds like a problem to develop an app based on behavior that's
 not required by any spec (or handled totally by your own code). :-)

 FWIW!
 -- 
 Hassan Schroeder - [EMAIL PROTECTED]
 Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

  dream.  code. 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



c:import doesn't work right with HEAD requests

2005-12-17 Thread erh

I'm having some trouble getting the c:import tag to work right.
It seems to be perfectly fine when the request that tomcat receives is
a GET request.  However, when it receives a HEAD request instead, c:import
never actually reads the data.
Is this a known bug?  Is it fixed in a more recent version of tomcat?
I'm using 5.0.30.

eric

Here's an example jsp file testit.jsp:
---cut---
%@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
c:import url=/testit.txt var=foo/
%
System.out.println(FOO:[ + pageContext.getAttribute(foo) + ]);
%
worked: ${foo}
---cut---

Here's testit.txt:
---cut---
data data data
---cut---

When I send a GET request to retrieve /myapp/testit.jsp, I get the expected
worked: data data data in the response, and in catalina.out I get:
---cut---
FOO:[data data data
]
---cut---
That's what I expect.  However, if I send a HEAD request I get no output
other than headers in the response (as I expect), but catalina.out has
this instead:
---cut---
FOO:[]
---cut---
Notice there's nothing inside the [].

Here's my HEAD request transcript:

poe: {50} telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HEAD /myapp/testit.jsp HTTP/1.1
Host: localhost:8080

HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=5A2DA89DDC03A24F4CF110EFD1BB6541; Path=/myapp
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 15
Date: Sun, 18 Dec 2005 05:29:54 GMT
Server: Apache-Coyote/1.1

^]
telnet c


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]