开发者

session in jsp/struts

I have 3 jsp, jsp1..jsp & jsp2.jsp have a button name "TEST", when user click on it - he gets forwarded to Test.jsp which dynamically changes depending on which jsp user has pressed TEST.

so depending on user where he comes from, I change the logic in action class to direct the user, for that I am passing sessions.

jsp1.jsp

<input type="hidden" name="jspType" value="M" property="jspType">

jsp2.jsp

<input type="hidden" name="jspType" value="C" property="jspType">

I开发者_StackOverflown the action class of my Test.jsp

TestAction.java

String jspTypeVariable = (String) request.getParameter("jspType");

later down in code

if(jspTypeVariable=="M")
{
system.out.println("Magic");
}
else if (jspTypeVariable=="C")
system.out.println("Cash");

==================================

It doesnt work? Any one help


You can't compare Strings with ==. == tests if both objects are the same instance, not if their contents is the same. Use if ("M".equals(jspTypeVariable)) instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜