You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sagarlotiya <sa...@aspl.in> on 2008/02/22 07:50:54 UTC

Regarding Localization Can't Change in Struts2

Hi,
I have some strange problem occurs in my application with using struts2.

When i will try to change locale without login it don't work.

But once i will login in to the application i can change the locale.

can any one help what can be the problem that i can't change the locale
without login... 

I am using Interceptor for login validation , does it creates any problems.?

Than you
-- 
View this message in context: http://www.nabble.com/Regarding-Localization-Can%27t-Change-in-Struts2-tp15628698p15628698.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Regarding Localization Can't Change in Struts2

Posted by sagarlotiya <sa...@aspl.in>.
hi
Thanks for your  help but finally i have found the solution and it is
following 

I have just put the <interceptor-ref name="i18n" /> before my login
interceptor and it works fine.



Laurie Harper wrote:
> 
> It still seems like the most likely cause is the login interceptor 
> invoking navigation (esp. via a redirect) before the locale switch can 
> happen.
> 
> Have you tried (temporarily) commenting out the login interceptor from 
> your defaultinterceptor stack? What about moving it down the stack (i.e. 
> after completeStack?
> 
> L.
> 
> sagarlotiya wrote:
>> Hi
>> 
>> My login jsp file contains only form which includes the username and
>> password text field nothing else.
>> Here i am pasting of my stack for Interceptor...
>> 
>> I have struts.xml file in that i have included my authentication.xml
>> 
>> the content of authentication.xml file is following...
>> 
>> <struts>
>> 	<package name="login" namespace="/login" extends="struts-default">
>> 		<interceptors>
>> 			<interceptor name="login" class="LoginInterceptor">
>> 			</interceptor>
>> 			
>> 			<interceptor-stack name="defaultinterceptor">
>> 				<interceptor-ref name="login"/>
>> 				<interceptor-ref name="completeStack"/>
>> 				<interceptor-ref name="execAndWait"/>
>> 			</interceptor-stack>
>> 		</interceptors>
>> 		
>> 		<global-results>
>> 			<result name="login" type="redirect">../login/login.action</result>
>> 			<result name="failure">authenticatFailure.jsp</result>
>> 			<result name="wait">Wait.jsp</result>
>> 			<result name="Exception">Exception.jsp</result>
>> 		</global-results>
>> 		
>> 				
>> 		
>> 		<action name="login" class="Login">
>> 			<interceptor-ref name="defaultinterceptor"/>
>> 			<result name="login">Login.jsp</result>
>> 		</action>
>> 		
>> 		<action name="logout" class="Login">
>> 			<interceptor-ref name="completeStack"/>
>> 			<interceptor-ref name="execAndWait"/>
>> 			<result name="login">Login.jsp</result>
>> 		</action>
>> 	</package>
>> </struts>
>> 
>> And following is the contents of my interceptor...
>> 
>> public String intercept(ActionInvocation actionInvocation) throws
>> Exception
>> {
>>  			
>>  	if(!(loggedInUser)) {
>>  		return Action.LOGIN;
>>  	}
>>  	else {
>>  		return actionInvocation.invoke();
>>  	}
>> }
>> 
>> Hope so above thing may help you some what to diagnosis the problem...
>> I have also tried to check without redirecting but then also it didn't
>> work
>> for me...
>> 
>> 
>> 
>> 
>> Laurie Harper wrote:
>>> Still not enough information to say for sure, but:
>>>
>>>  > login otherwise redirect back that user to login page...
>>> ...
>>>  > i am passing request_locale paramter in url
>>>
>>> you realize that a redirect will lose the request parameter, right?
>>>
>>> If that isn't the clue you're looking for, post some configuration:
>>>
>>> - your interceptor stack
>>> - action/result mappings in struts.xml for Action.LOGIN
>>> - relevant code from your login page JSP
>>>
>>> L.
>>>
>>> sagarlotiya wrote:
>>>> hi
>>>> you are right?
>>>> Let me describe the problem in detail.
>>>>
>>>> i have one application in struts2.
>>>>
>>>> I have made one interceptor that is called Login Interceptor in that i
>>>> am
>>>> checking for whether user is valid or not If valid then i will allow
>>>> them
>>>> to
>>>> login otherwise redirect back that user to login page...
>>>>
>>>> I am achieving this thing using Login Interceptor...
>>>>
>>>> Now suppose if user loggin successfully and then try to change the
>>>> localization it works...
>>>> but suppose if user fails to loggin and then will try to change the
>>>> localization it doesn't work...
>>>>
>>>> see my code of interceptor
>>>>
>>>> public String intercept(ActionInvocation actionInvocation) throws
>>>> Exception
>>>> {
>>>> 			
>>>> 	if(!(loggedInUser)) {
>>>> 		return Action.LOGIN;
>>>> 	}
>>>> 	else {
>>>> 		return actionInvocation.invoke();
>>>> 	}
>>>> }
>>>>
>>>> in above if i am in "If" part then i can't change the
>>>> localization...though
>>>> i am passing request_locale paramter in url
>>>>
>>>> but if usr is valid and "ELSE" part is there in above code it doesn't
>>>> work...
>>>>
>>>> so above is the problem..
>>>>
>>>> help me if possible... i have tried a lot but i can't find what is the
>>>> problem?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> newton.dave wrote:
>>>>> --- sagarlotiya <sa...@aspl.in> wrote:
>>>>>> When i will try to change locale without login it don't work.
>>>>>>
>>>>>> But once i will login in to the application i can change the locale.
>>>>>>
>>>>>> I am using Interceptor for login validation , does it creates any
>>>>> problems.?
>>>>>
>>>>> Hard to say.
>>>>>
>>>>> You haven't really provided enough information with which to start
>>>>> diagnosing
>>>>> the problem.
>>>>>
>>>>> Dave
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Regarding-Localization-Can%27t-Change-in-Struts2-tp15628698p15705811.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Regarding Localization Can't Change in Struts2

Posted by Laurie Harper <la...@holoweb.net>.
It still seems like the most likely cause is the login interceptor 
invoking navigation (esp. via a redirect) before the locale switch can 
happen.

Have you tried (temporarily) commenting out the login interceptor from 
your defaultinterceptor stack? What about moving it down the stack (i.e. 
after completeStack?

L.

sagarlotiya wrote:
> Hi
> 
> My login jsp file contains only form which includes the username and
> password text field nothing else.
> Here i am pasting of my stack for Interceptor...
> 
> I have struts.xml file in that i have included my authentication.xml
> 
> the content of authentication.xml file is following...
> 
> <struts>
> 	<package name="login" namespace="/login" extends="struts-default">
> 		<interceptors>
> 			<interceptor name="login" class="LoginInterceptor">
> 			</interceptor>
> 			
> 			<interceptor-stack name="defaultinterceptor">
> 				<interceptor-ref name="login"/>
> 				<interceptor-ref name="completeStack"/>
> 				<interceptor-ref name="execAndWait"/>
> 			</interceptor-stack>
> 		</interceptors>
> 		
> 		<global-results>
> 			<result name="login" type="redirect">../login/login.action</result>
> 			<result name="failure">authenticatFailure.jsp</result>
> 			<result name="wait">Wait.jsp</result>
> 			<result name="Exception">Exception.jsp</result>
> 		</global-results>
> 		
> 				
> 		
> 		<action name="login" class="Login">
> 			<interceptor-ref name="defaultinterceptor"/>
> 			<result name="login">Login.jsp</result>
> 		</action>
> 		
> 		<action name="logout" class="Login">
> 			<interceptor-ref name="completeStack"/>
> 			<interceptor-ref name="execAndWait"/>
> 			<result name="login">Login.jsp</result>
> 		</action>
> 	</package>
> </struts>
> 
> And following is the contents of my interceptor...
> 
> public String intercept(ActionInvocation actionInvocation) throws Exception
> {
>  			
>  	if(!(loggedInUser)) {
>  		return Action.LOGIN;
>  	}
>  	else {
>  		return actionInvocation.invoke();
>  	}
> }
> 
> Hope so above thing may help you some what to diagnosis the problem...
> I have also tried to check without redirecting but then also it didn't work
> for me...
> 
> 
> 
> 
> Laurie Harper wrote:
>> Still not enough information to say for sure, but:
>>
>>  > login otherwise redirect back that user to login page...
>> ...
>>  > i am passing request_locale paramter in url
>>
>> you realize that a redirect will lose the request parameter, right?
>>
>> If that isn't the clue you're looking for, post some configuration:
>>
>> - your interceptor stack
>> - action/result mappings in struts.xml for Action.LOGIN
>> - relevant code from your login page JSP
>>
>> L.
>>
>> sagarlotiya wrote:
>>> hi
>>> you are right?
>>> Let me describe the problem in detail.
>>>
>>> i have one application in struts2.
>>>
>>> I have made one interceptor that is called Login Interceptor in that i am
>>> checking for whether user is valid or not If valid then i will allow them
>>> to
>>> login otherwise redirect back that user to login page...
>>>
>>> I am achieving this thing using Login Interceptor...
>>>
>>> Now suppose if user loggin successfully and then try to change the
>>> localization it works...
>>> but suppose if user fails to loggin and then will try to change the
>>> localization it doesn't work...
>>>
>>> see my code of interceptor
>>>
>>> public String intercept(ActionInvocation actionInvocation) throws
>>> Exception
>>> {
>>> 			
>>> 	if(!(loggedInUser)) {
>>> 		return Action.LOGIN;
>>> 	}
>>> 	else {
>>> 		return actionInvocation.invoke();
>>> 	}
>>> }
>>>
>>> in above if i am in "If" part then i can't change the
>>> localization...though
>>> i am passing request_locale paramter in url
>>>
>>> but if usr is valid and "ELSE" part is there in above code it doesn't
>>> work...
>>>
>>> so above is the problem..
>>>
>>> help me if possible... i have tried a lot but i can't find what is the
>>> problem?
>>>
>>>
>>>
>>>
>>>
>>> newton.dave wrote:
>>>> --- sagarlotiya <sa...@aspl.in> wrote:
>>>>> When i will try to change locale without login it don't work.
>>>>>
>>>>> But once i will login in to the application i can change the locale.
>>>>>
>>>>> I am using Interceptor for login validation , does it creates any
>>>> problems.?
>>>>
>>>> Hard to say.
>>>>
>>>> You haven't really provided enough information with which to start
>>>> diagnosing
>>>> the problem.
>>>>
>>>> Dave
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 


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


Re: Regarding Localization Can't Change in Struts2

Posted by sagarlotiya <sa...@aspl.in>.
Hi

My login jsp file contains only form which includes the username and
password text field nothing else.
Here i am pasting of my stack for Interceptor...

I have struts.xml file in that i have included my authentication.xml

the content of authentication.xml file is following...

<struts>
	<package name="login" namespace="/login" extends="struts-default">
		<interceptors>
			<interceptor name="login" class="LoginInterceptor">
			</interceptor>
			
			<interceptor-stack name="defaultinterceptor">
				<interceptor-ref name="login"/>
				<interceptor-ref name="completeStack"/>
				<interceptor-ref name="execAndWait"/>
			</interceptor-stack>
		</interceptors>
		
		<global-results>
			<result name="login" type="redirect">../login/login.action</result>
			<result name="failure">authenticatFailure.jsp</result>
			<result name="wait">Wait.jsp</result>
			<result name="Exception">Exception.jsp</result>
		</global-results>
		
				
		
		<action name="login" class="Login">
			<interceptor-ref name="defaultinterceptor"/>
			<result name="login">Login.jsp</result>
		</action>
		
		<action name="logout" class="Login">
			<interceptor-ref name="completeStack"/>
			<interceptor-ref name="execAndWait"/>
			<result name="login">Login.jsp</result>
		</action>
	</package>
</struts>

And following is the contents of my interceptor...

public String intercept(ActionInvocation actionInvocation) throws Exception
{
 			
 	if(!(loggedInUser)) {
 		return Action.LOGIN;
 	}
 	else {
 		return actionInvocation.invoke();
 	}
}

Hope so above thing may help you some what to diagnosis the problem...
I have also tried to check without redirecting but then also it didn't work
for me...




Laurie Harper wrote:
> 
> Still not enough information to say for sure, but:
> 
>  > login otherwise redirect back that user to login page...
> ...
>  > i am passing request_locale paramter in url
> 
> you realize that a redirect will lose the request parameter, right?
> 
> If that isn't the clue you're looking for, post some configuration:
> 
> - your interceptor stack
> - action/result mappings in struts.xml for Action.LOGIN
> - relevant code from your login page JSP
> 
> L.
> 
> sagarlotiya wrote:
>> 
>> hi
>> you are right?
>> Let me describe the problem in detail.
>> 
>> i have one application in struts2.
>> 
>> I have made one interceptor that is called Login Interceptor in that i am
>> checking for whether user is valid or not If valid then i will allow them
>> to
>> login otherwise redirect back that user to login page...
>> 
>> I am achieving this thing using Login Interceptor...
>> 
>> Now suppose if user loggin successfully and then try to change the
>> localization it works...
>> but suppose if user fails to loggin and then will try to change the
>> localization it doesn't work...
>> 
>> see my code of interceptor
>> 
>> public String intercept(ActionInvocation actionInvocation) throws
>> Exception
>> {
>> 			
>> 	if(!(loggedInUser)) {
>> 		return Action.LOGIN;
>> 	}
>> 	else {
>> 		return actionInvocation.invoke();
>> 	}
>> }
>> 
>> in above if i am in "If" part then i can't change the
>> localization...though
>> i am passing request_locale paramter in url
>> 
>> but if usr is valid and "ELSE" part is there in above code it doesn't
>> work...
>> 
>> so above is the problem..
>> 
>> help me if possible... i have tried a lot but i can't find what is the
>> problem?
>> 
>> 
>> 
>> 
>> 
>> newton.dave wrote:
>>> --- sagarlotiya <sa...@aspl.in> wrote:
>>>> When i will try to change locale without login it don't work.
>>>>
>>>> But once i will login in to the application i can change the locale.
>>>>
>>>> I am using Interceptor for login validation , does it creates any
>>> problems.?
>>>
>>> Hard to say.
>>>
>>> You haven't really provided enough information with which to start
>>> diagnosing
>>> the problem.
>>>
>>> Dave
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Regarding-Localization-Can%27t-Change-in-Struts2-tp15628698p15648300.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Regarding Localization Can't Change in Struts2

Posted by Laurie Harper <la...@holoweb.net>.
Still not enough information to say for sure, but:

 > login otherwise redirect back that user to login page...
...
 > i am passing request_locale paramter in url

you realize that a redirect will lose the request parameter, right?

If that isn't the clue you're looking for, post some configuration:

- your interceptor stack
- action/result mappings in struts.xml for Action.LOGIN
- relevant code from your login page JSP

L.

sagarlotiya wrote:
> 
> hi
> you are right?
> Let me describe the problem in detail.
> 
> i have one application in struts2.
> 
> I have made one interceptor that is called Login Interceptor in that i am
> checking for whether user is valid or not If valid then i will allow them to
> login otherwise redirect back that user to login page...
> 
> I am achieving this thing using Login Interceptor...
> 
> Now suppose if user loggin successfully and then try to change the
> localization it works...
> but suppose if user fails to loggin and then will try to change the
> localization it doesn't work...
> 
> see my code of interceptor
> 
> public String intercept(ActionInvocation actionInvocation) throws Exception
> {
> 			
> 	if(!(loggedInUser)) {
> 		return Action.LOGIN;
> 	}
> 	else {
> 		return actionInvocation.invoke();
> 	}
> }
> 
> in above if i am in "If" part then i can't change the localization...though
> i am passing request_locale paramter in url
> 
> but if usr is valid and "ELSE" part is there in above code it doesn't
> work...
> 
> so above is the problem..
> 
> help me if possible... i have tried a lot but i can't find what is the
> problem?
> 
> 
> 
> 
> 
> newton.dave wrote:
>> --- sagarlotiya <sa...@aspl.in> wrote:
>>> When i will try to change locale without login it don't work.
>>>
>>> But once i will login in to the application i can change the locale.
>>>
>>> I am using Interceptor for login validation , does it creates any
>> problems.?
>>
>> Hard to say.
>>
>> You haven't really provided enough information with which to start
>> diagnosing
>> the problem.
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 


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


Re: Regarding Localization Can't Change in Struts2

Posted by sagarlotiya <sa...@aspl.in>.

hi
you are right?
Let me describe the problem in detail.

i have one application in struts2.

I have made one interceptor that is called Login Interceptor in that i am
checking for whether user is valid or not If valid then i will allow them to
login otherwise redirect back that user to login page...

I am achieving this thing using Login Interceptor...

Now suppose if user loggin successfully and then try to change the
localization it works...
but suppose if user fails to loggin and then will try to change the
localization it doesn't work...

see my code of interceptor

public String intercept(ActionInvocation actionInvocation) throws Exception
{
			
	if(!(loggedInUser)) {
		return Action.LOGIN;
	}
	else {
		return actionInvocation.invoke();
	}
}

in above if i am in "If" part then i can't change the localization...though
i am passing request_locale paramter in url

but if usr is valid and "ELSE" part is there in above code it doesn't
work...

so above is the problem..

help me if possible... i have tried a lot but i can't find what is the
problem?





newton.dave wrote:
> 
> --- sagarlotiya <sa...@aspl.in> wrote:
>> When i will try to change locale without login it don't work.
>> 
>> But once i will login in to the application i can change the locale.
>> 
>> I am using Interceptor for login validation , does it creates any
> problems.?
> 
> Hard to say.
> 
> You haven't really provided enough information with which to start
> diagnosing
> the problem.
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Regarding-Localization-Can%27t-Change-in-Struts2-tp15628698p15630922.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Regarding Localization Can't Change in Struts2

Posted by Dave Newton <ne...@yahoo.com>.
--- sagarlotiya <sa...@aspl.in> wrote:
> When i will try to change locale without login it don't work.
> 
> But once i will login in to the application i can change the locale.
> 
> I am using Interceptor for login validation , does it creates any
problems.?

Hard to say.

You haven't really provided enough information with which to start diagnosing
the problem.

Dave


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