• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

A little issue with <c:set ...>

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a problem attempting to get an attribute that has been set in a JSP, I'm using Struts as a framework and the Action class is where I wanna get the attribute that's been set.


JSP:


Action:


Can anyone give me a hand please???

Regards.
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gustavo Santos wrote:I'm having a problem attempting to get an attribute that has been set in a JSP, I'm using Struts as a framework and the Action class is where I wanna get the attribute that's been set.



What is the relationship of this JSP and the Action class? If the JSP is the view of the action, it's rendered AFTER the action method has returned!

Why would you like to set those values in the JSP?
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of where the scope attribute is going to be set in the <c:set> and how you are trying to retrieve it?
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lorand Komaromi wrote:

Gustavo Santos wrote:I'm having a problem attempting to get an attribute that has been set in a JSP, I'm using Struts as a framework and the Action class is where I wanna get the attribute that's been set.



What is the relationship of this JSP and the Action class? If the JSP is the view of the action, it's rendered AFTER the action method has returned!

Why would you like to set those values in the JSP?



I got the values from a form and when I click on another link, I want the same values that has been set on that form to be used on the "contact_action", does that make sense?



 
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, using <c:set> to place the values into page scope just isn't going to accomplish anything.

Why aren't you just submitting the values as parameters? Why all the complications?
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gustavo Santos wrote:I got the values from a form and when I click on another link, I want the same values that has been set on that form to be used on the "contact_action"



Pass them to the action as GET parameters. I don't know how to do that in Struts 1.
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK! Thank you so much guys! I passed it as a parameter... does anyone know how to pass more than just one parameter???

anyway, It turned out that I got another issue... which is that I want to pass a Map to another Action, shouldn't I set it as an Attribute then retrieve it on my Action ?
 
Bear Bibeault
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can pass as many parameters as you want. Do you think forms are limited to a single field?

Scoped variables (the proper term for "attributes") placed in session scope should be used sparingly across requests. Check your logic for a design flaw before proceeding. Why do you need to pass this data around?
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
alright... now I got how to pass more than one String parameter, by using:



now the issue is... how can I pass a Map to another Action class? through an Attribute or what?
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You can pass as many parameters as you want. Do you think forms are limited to a single field?

Scoped variables (the proper term for "attributes") placed in session scope should be used sparingly across requests. Check your logic for a design flaw before proceeding. Why do you need to pass this data around?



I want to pass the Map because I can use it instead of doing another search on my DataBase.
 
Bear Bibeault
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then why aren't you caching it in the data access layer? Passing it around in the presentation layer is just a mess.
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Then why aren't you caching it in the data access layer? Passing it around in the presentation layer is just a mess.



Thanks for the quick reply! but I'm sorry this is the first project (with JSP & Struts I mean) I'm working on and I have no idea what you're talking about, can you please be a little bit more specific?

Many thanks!
 
Bear Bibeault
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any such caching for DB performance reasons is not the job of the UI (presentation layer). Whatever layer you have designed to fetch the data from the DB should be abstracting that process from the UI and can be written to cache the data rather than having to go back to the DB each time.

But this should be entirely transparent to the UI code.

Mixing data access code into the UI is a very, very, and did I mention very, poor practice.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic