File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

variable value not being passed to jsp from Action

 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

This is what i am doing

declared a variable called ack in the action class, created the getter setters for the same.
variable is getting it s value from a function

I am trying to access this variable in a jsp called menubar.jsp.
it is a generic jsp, a jsp which is used everywhere

i have a If loop in the jsp, to check for a particular value in the variable, not able to do so, as the value is not being passed

help please

jsp code



>








 
suraj savaratkar
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
you must put the values into request or seeeion and this 'request or seeeion' iterate over the '.jsp'and you able to
get the values into the '.jsp'
 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, how do i do that ?
not very sure on this.

Actually, i have done a similar implementation where i check for count, and i was able to do it.

i also understand that struts 2 has the capability where you can access the values in the jsp, as it is automatically placed in the session.

not sure how right i am
 
suraj savaratkar
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you want to store in request then you have to be getter and setter method of that object.
and getin '.jsp' using <s:property values="#request.objectname"> then you get the values of that object.
 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So my code should look like this after your suggestion

<s:if test="%{ackvalue == 'WES'}">
<s:property value="request.ackValue"/>
<li id="logoutMenu" ><a id="logout"

correct ?

Session Put Statement in Action class

session.put(ackValue,ConflictConstants.SESSION_ATTRIBURE_ACK_VALUE);
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sankey jain wrote:i also understand that struts 2 has the capability where you can access the values in the jsp, as it is automatically placed in the session.

Nothing is automatically placed in the session.
sankey jain wrote:

That's almost certainly not what you meant, although it would work. The key value is first--it's just a map.
 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
sankey jain wrote:i also understand that struts 2 has the capability where you can access the values in the jsp, as it is automatically placed in the session.

Nothing is automatically placed in the session.
sankey jain wrote:

That's almost certainly not what you meant, although it would work. The key value is first--it's just a map.


okay, understood.
i guess the jsp, action class are tagged together by a particular action in the struts.xml
that is how i was able to do the above in one instance.

So using the session statement and session.request in the jsp, i can retrieve the value.
right ?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sankey jain wrote:[...] and session.request in the jsp, i can retrieve the value.

I don't know what you mean by "session.request".

Wouldn't it just be easier to try something, and if it doesn't work, PostRealCode and ask a question?
 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i have done now



ConflictConstants.SESSION_ATTRIBURE_ACK_VALUE constant's value is ackval

Now, when i switch to debug, the value for ackValue is populated
How do i access the variable in the Jsp ?

Below is the code where i want to access it, have placed my comments accordingly



 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
sankey jain wrote:[...] and session.request in the jsp, i can retrieve the value.

I don't know what you mean by "session.request".

Wouldn't it just be easier to try something, and if it doesn't work, PostRealCode and ask a question?


This is what i have done now



ConflictConstants.SESSION_ATTRIBURE_ACK_VALUE constant's value is ackval

Now, when i switch to debug, the value for ackValue is populated
How do i access the variable in the Jsp ?

Below is the code where i want to access it, have placed my comments accordingly



 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#session.whateverATTRIBUREis

Fix the typo.

You can also probably do something like #session[@full.constants.package@ATTRIBURE]
 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:#session.whateverATTRIBUREis

Fix the typo.

You can also probably do something like #session[@full.constants.package@ATTRIBURE]


Hi David,

Thanks a lot for the support :).. Appreciate it
have done the below

hope it works

 
sankey jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sankey jain wrote:
David Newton wrote:#session.whateverATTRIBUREis

Fix the typo.

You can also probably do something like #session[@full.constants.package@ATTRIBURE]


Hi David,

Thanks a lot for the support :).. Appreciate it
have done the below

hope it works




The Above worked.. Thanks a lot for the help
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic