[s2] redirect and URLEncoding

2007-09-20 Thread Alex Funk

Hi,

I am building a web application with Struts2 and Tomcat 5.5 as the web 
container. One action parameter is passed as part of the URL and may

contain Unicode characters:
action name=article/* class=...
   param name=title{1}/param
   result/ShowArticle.jsp/result
/action

The s:url tag encodes this parameter as UTF-8, and I declared in my 
tomcat server.xml the matching encoding

Connector URIEncoding=UTF-8 ... port=8081 /

So far, so good. Everything works fine. Trouble starts when I use 
redirect results or redirect-action result with Unicode characters in 
the title part of the url:


action name=editarticle/* class=...
   param name=title{1}/param
   result name=save type=redirectarticle/${title}/result
   ...
/action

Than the redirect URL is encoded in ISO-8859-1, which is than 
misinterpreted as UTF-8 when send back to tomcat. While debugging I 
think this encoding is done in HTTPServletResponse#sendRedirect by default.


I can workaround that by introducing a new attribute to my action class:

public String getTitleURLEncoded() throws Exception {
  return URLEncoder.encode(getTitle(), UTF-8);
}

and change the result to

result name=save type=redirectarticle/${titleURLEncoded}/result

This works, but it 'feels' wrong. Is there some other solution to this? 
Any input is welcome.


Best regards, Alex


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



Re: 'root' is not allowed as status in s:iterator?

2007-09-15 Thread Alex Funk

Dave Newton wrote:

--- Alex Funk [EMAIL PROTECTED] wrote:

Is this a bug or a feature?


root may refer to the root of the OGNL stack, but I
can't verify that at the moment. You could probably
test that theory, though.

Thanks for the reply, Dave.

Yes, s:property value=#root/ returns the value stack. But I wonder 
how and why this is blocking the entire namespace starting with 'root'.
If I use 'request' as the iterator status, everything works as I would 
expect:

s:iterator status=request value={1,2} 
   #request.index = s:property value=#request.index /
   br/
/s:iterator

Well, as soon as one knows it, one can work around it. I am quite new to 
Struts2 and not sure if this is some sort of misconfiguration on my 
side. If anyone else can reproduce this, I would report this as a bug in 
Jira, or at least leave a comment on 
http://cwiki.apache.org/confluence/display/WW/iterator


Thanks again,

Alex

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



'root' is not allowed as status in s:iterator?

2007-09-14 Thread Alex Funk

Hi,

after some debugging I found that I can't use any identifier starting 
with 'root' as status in s:iterator. The following code in my jsp:

---
p
s:iterator status=stat value={1,2,3,4,5} 
   #stat.index = s:property value=#stat.index /br/
/s:iterator
/pp
s:iterator status=root value={1,2,3,4,5} 
   #root.index =s:property value=#root.index /br/
/s:iterator
/pp
s:iterator status=rootAtTheBeginOfIdentifier value={1,2,3,4,5} 
   #rootAtTheBeginOfIdentifier.index =s:property 
value=#rootAtTheBeginOfIdentifier.index / br/

/s:iterator
/p
---
gives this result:
#stat.index = 0
#stat.index = 1
#stat.index = 2
#stat.index = 3
#stat.index = 4

#root.index =
#root.index =
#root.index =
#root.index =
#root.index =

#rootAtTheBeginOfIdentifier.index =
#rootAtTheBeginOfIdentifier.index =
#rootAtTheBeginOfIdentifier.index =
#rootAtTheBeginOfIdentifier.index =
#rootAtTheBeginOfIdentifier.index =
--

Can someone reproduce this? Is this a bug or a feature?

Best regards,

Alex

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