Re: Action bean cannot get correct utf-8 character

2017-12-18 Thread Yasser Zamani


On 12/19/2017 1:38 AM, Emi wrote:
> Value entered é in jsp
> 
> 
> (3) Action bean get value:   é.
> 
> 
> Can someone let me know what config is wrong/missing please?

Have you checked your container (e.g. tomcat, jetty, etc) config? for 
example in tomcat, add "URIEncoding="UTF-8" attribute to your Connector 
in server.xml. like `` [1].

I hope this helps.

[1] https://wiki.apache.org/tomcat/FAQ/CharacterEncoding

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


Action bean cannot get correct utf-8 character

2017-12-18 Thread Emi

Hello,

For struts2.5.14.1, I have an issue with utf-8 encoding (jsp submit to 
action class; bean get wrong character).


(1) web.xml


*.jsp
UTF-8





set character encoding
setCharacterEncodingFilter
SetCharacterEncodingFilter

encoding
UTF-8



   
setCharacterEncodingFilter
   /*
   


(2) jsp page
<%@ page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8"%>




Value entered é in jsp


(3) Action bean get value:   é.


Can someone let me know what config is wrong/missing please?

Thanks a lot!



Re: java.lang.ClassCastException: org.apache.struts2.dispatcher.mapper.ActionMapping

2017-12-18 Thread Yasser Zamani


On 12/18/2017 8:33 PM, Prasanth Pasala wrote:
> Added it to Struts JIRA (WW-4904)

Thank you very much for your time and report!

>  If I set the struts.actionMapping attribute to null it still causes the 
> class cast exception. What I have seen is that after setting it to null if 
> you call
> getAttribute you would still get the old ActionMapping object, not sure how 
> that is possible.

Hmm... so how and why `request.setAttribute("struts.valueStack", null)` 
works.

That's weird and so very important to me :)

Could you please see what is the type of request when you receive it in 
your second context filter? e.g. println(request.getType()) before those 
your two lines (I could see myself but maybe it will be different from 
your one!)

Thanks in advance!


Re: java.lang.ClassCastException: org.apache.struts2.dispatcher.mapper.ActionMapping

2017-12-18 Thread Prasanth Pasala
Added it to Struts JIRA (WW-4904) If I set the struts.actionMapping attribute 
to null it still causes the class cast exception. What I have seen is that 
after setting it to null if you call
getAttribute you would still get the old ActionMapping object, not sure how 
that is possible. Thanks, Prasanth 
--- 
[show/hide
original text]
No it's not a Struts issue. You don't see this in Struts1 because maybe 
it doesn't use any object bounded to dispatched request. But Struts2 
wants to

ActionMapping mapping = 
(ActionMapping)request.getAttribute("struts.actionMapping");

A workaround would be removing object with key "struts.actionMapping" 
from request before dispatching.

I hope this helps.



On 12/15/2017 04:54 PM, Prasanth Pasala wrote:
> Added the below two lines to my filter (before the struts2 filter) in 
> context2 app. That seems to do the trick. Thought it might create a problem 
> as I am setting a new ActionMapping in the request,
> but seems to work fine. Do you see any side effects of this?
>
>         request.setAttribute("struts.actionMapping", new ActionMapping());
>         request.setAttribute("struts.valueStack", null);
>
> Thanks,
> Prasanth
>
> On 12/15/2017 04:10 PM, Prasanth Pasala wrote:
>> It seems like removeAttribute or setAttribute is not getting rid of the 
>> attribute from request. See below. If I set the value to a random string 
>> then I get a String can't be cast to ActionMapping
>> exception.
>>
>>    Enumeration attrs = request.getAttributeNames();
>>         while(attrs.hasMoreElements()) {
>>             System.out.println(attrs.nextElement());
>>         }
>>         System.out.println(request.getAttribute("struts.actionMapping"));
>>         request.setAttribute("struts.actionMapping", null);
>>         System.out.println(request.getAttribute("struts.actionMapping"));
>>
>> Output:
>> 16:05:05,300 INFO  [stdout] (default task-13) 
>> javax.servlet.forward.context_path
>> 16:05:05,302 INFO  [stdout] (default task-13) 
>> javax.servlet.forward.servlet_path
>> 16:05:05,303 INFO  [stdout] (default task-13) 
>> javax.servlet.forward.request_uri
>> 16:05:05,303 INFO  [stdout] (default task-13) javax.servlet.forward.path_info
>> 16:05:05,303 INFO  [stdout] (default task-13) 
>> javax.servlet.forward.query_string
>> 16:05:05,303 INFO  [stdout] (default task-13) javax.servlet.request.key_size
>> 16:05:05,303 INFO  [stdout] (default task-13) __cleanup_recursion_counter
>> 16:05:05,303 INFO  [stdout] (default task-13) 
>> javax.servlet.request.cipher_suite
>> 16:05:05,304 INFO  [stdout] (default task-13) struts.valueStack
>> 16:05:05,308 INFO  [stdout] (default task-13) 
>> javax.servlet.request.ssl_session_id
>> 16:05:09,121 INFO  [stdout] (default task-13) ActionMapping{name='Login', 
>> namespace='/', method='null', extension='action', params=null, result=null}
>> 16:05:10,960 INFO  [stdout] (default task-13) ActionMapping{name='Login', 
>> namespace='/', method='null', extension='action', params=null, result=null}
>>
>>
>> On 12/15/2017 02:28 PM, Prasanth Pasala wrote:
>>> Thanks for the prompt response. Tried removing the attribute from the 
>>> request, but still getting the class cast exception. Is it possible it is 
>>> being set after I have called the forward?    
>>> request.removeAttribute("struts.actionMapping");     // FORWARD THE REQUEST 
>>>     ServletContext sContext = context.getContext("/context2");     
>>> RequestDispatcher rd =
>>> sContext.getRequestDispatcher("/Login.action");    rd.forward(request, 
>>> response);    [show/hide original text]
>>> No it's not a Struts issue. You don't see this in Struts1 because maybe 
>>> it doesn't use any object bounded to dispatched request. But Struts2 
>>> wants to
>>>
>>> ActionMapping mapping = 
>>> (ActionMapping)request.getAttribute("struts.actionMapping");
>>>
>>> A workaround would be removing object with key "struts.actionMapping" 
>>> from request before dispatching.
>>>
>>> I hope this helps.
>>>
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: user-h...@struts.apache.org    
>>
>