File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes using OGNL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "using OGNL" Watch "using OGNL" New topic

using OGNL

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I have 2 jsp's...

Jsp1 needs a value to be calculated and fetched from jsp2...

so control comes from login--->jsp1--->jsp2--->jsp1

I know scriptlets should be avoided as much as possible...

so use of OGNL in jsp1 would suffice,like say storing the value in jsp2 in a session and access in jsp1??

My app is in struts-2 and I am not sure what would happen to the OGNL statement I write in jsp1,i.e when control comes from login-jsp1(before the value is calclulated)

I would give important piece of related code...

In jsp1:-->

A row is selected and button is clicked to go to jsp2...

IN Jsp2 I do AJax call and sending the 2 values that should be set to the selected row of jsp1...

I think the above style of getting jsp1 table and doing it is incorrect...what should be done ? how to use OGNL here?

Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

I personally cannot understand anything in your code even after going through it 3 times. Your JSPs are talking to each other without using any action, I cannot understand that design in the first place. Now if control transfers from JSP1 to JSP2, then making an ajax request to JSP1 doesn't makes sense as JSP1 is not displayed anywhere or any window or tab in the browser. You made an AJAX request to JSP1 from JSP2 and did nothing with the response. And how is JSP1 using the request parameters that you are sending to it?? Also if you want to set session or other scoped attributes in a JSP, you can use c:set JSTL tag...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Ok! I'll make it clear about my issue...


Table with 'n' rows and 6 columns in UI...Only 4 columns are filled for all rows an rest 2 are empty.The user needs to select a row and click on button to go to jsp2


I prepared the values and have them in javascript ! Now on click of Add button the control goes back to jsp1 but the 2 cells of the row which was selected before should be updated with the 2 javascript values that are there in jsp2


How should I transfer them to the appropriate cells of selected row?

1)I made an Ajax call as shown above but it looks fruitless as they come into action class and went nowhere...

If this is the right way then I would post the Action class for jsp 2 that responds to Ajax call !

Need expert advice and no hesitations if suggested a revamp on how to set those values present in jsp2 in the empty cells of selected row of jsp1!

I agree. Here's the link:
subject: using OGNL
jQuery in Action, 3rd edition