• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL to put value in request  RSS feed

 
SachinJ Joshi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am fetching records from result set and displaying on JSP with <c:forEach> tag


Below is one row with radio button
SourceIndex ProductAbbreviation Product Name Effective Date UseID
ABC PQR Test123 03/12/2014 smj

I have a view button also to select above radio button. When I select that I need all above values to be set in request.
Can some one please help for this?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.

I've gone ahead and added the code tags for you. See how much easier the code is to read?
 
SachinJ Joshi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah. thats true. thanks a lot.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, JSTL will be of no help to you in sending a request. The JSTL, like the rest of the JSP, executes on the server to send a plain old HTML page to the client. There is no more JSP-ness to the page after that. If that's unclear, please see this article.

Secondly, your description is not clear. Why would you have a button to set another button? Perhaps you should show us the buttons rather than just tell us about them.

Lastly, generally the easiest way to collect data to send on another request is to collect them into hidden fields. That's a tad old-fashioned these days -- with JavaScript activity being the modern approach -- but it works if JavaScript isn't your thing yet. (Note: if you are working on the web, JavaScript should become "your thing" very quickly. Anyone not highly skilled in JavaScript will not be working on the web much longer.)
 
SachinJ Joshi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have multiple records. Each record has 5 values --> Source Index, Product Abbreviation, Product Name, Effective Date, UserID with readio button to select a particular record.
And to view each record in detail I have VIEW button.

When a radio button is selected and VIEW button is cliecked; a Servlet will be called and I want those 5 values of that particular record to be used in that Servlet.
Is my explaination clear?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somewhat.

I'd say that this is a poor approach. Better and more common is for the primary key of the item to be sent, rather than all the fields of the item, and for the item to be retrieved from the DB afresh. (I'm assuming that all your records come from a DB, and that each row has a clad primary key.)
 
SachinJ Joshi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Primary Key = SourceIdx + Product Code Abbr.
So to get rest of the details from databse based on above primary key I should have SourceIdx and Product Code Abbr. in request so that I can use in JAVA.

How to get those two parameters for a particular record selected?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, another not-so-great practice: using business values for the primary key. Best practice is to have a numeric primary key that means nothing -- it's just an id value.

Any chance you can refactor your tables? It's a lot easier to deal with not only primary keys that aren't subject to change (business values frequently are), but to deal with a single value.

Either way, unless you want to get off into JavaScript, I'd go the hidden field approach.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!