cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Cordes <mcord...@maine.edu>
Subject Re: Odd java XSP problem with hashtables and javax.servlet.http.HttpUtils
Date Tue, 10 Apr 2001 21:47:02 GMT
Hi, 

Althought another poster answered your question, I'd like to point 
out that the line
> 		  Hashtable qs = new Hashtable();

is not needed as 
> 		  	qs = HttpUtils.parseQueryString(request.getQueryString());

creates a new hashtable and replaces the one you created above (e.g.
qs is a pointer to a hashtable, then the pointer is moved to a new hashtable).

-matt


On Tue, Apr 10, 2001 at 11:40:18AM -0700, Jay Wright wrote:
> 
> I'm having an odd problem.
> 
> I'm parsing a query string with javax.servlet.http.HttpUtils which throws it
> into a hashtable.  This works fine when I access this variable through
> <xsp:expr> and it simply places that object in an element.  It wont work if
> I try casting that object to String (all hashtable values are of type
> java.lang.Object)or if I try to access it through <xsp:attribute> first,
> calling <xsp:expr> within it (which imposes a cast on it within the cocoon
> generated java code).
> 
> Works Fine:
> 	<xsp:logic>
> 	<![CDATA[
> 		if ((request.getMethod()).equals("GET")) {
> 		  String queryString = request.getQueryString();
> 		  Hashtable qs = new Hashtable();
> 		  if (queryString != null) {
> 		  	qs = HttpUtils.parseQueryString(request.getQueryString());
> 	]]>
> 	</xsp:logic>
> 	<contactID>
> 		<xsp:expr>qs.get("contactID")</xsp:expr>
> 	</contactID>
> 
> Wont work:
> 	1. Casting with (String)qs.get("contactID")
> 	2. String.valueOf(qs.get("contactID"))
> 	3. (qs.get("contactID").toString()
> 
> 	I must be missing something because I can't see why I cannot cast the
> Ojbect (qs.get returns type Object) to a String and use the value.  Instead
> I get a [Ljava.lang.String;@2da3d cast exception thrown at me.
> 
> Any ideas.
> 
> I know this might be more of a java problem than xsp problem, but I posted
> here hoping that someone had a clever way around this (and getting at the
> query string parameters in xsp).
> 
> Jay
> 
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> 

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message