It's not a secret anymore!*
The moose likes JSP and the fly likes get the value in a jsp page to the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "get the value in a jsp page to the servlet" Watch "get the value in a jsp page to the servlet" New topic
Author

get the value in a jsp page to the servlet

gayatri umesh
Greenhorn

Joined: Aug 26, 2009
Posts: 17
//styleDetail.jsp



//ProductController.java



When i run the above code, a table is displayed with links. when i click on the link, the control is passed to the servlet 'ProductController' and i want to get the value of the link i have clicked.... If suppose the link clicked is 'ABC', this value should be read in the servlet..When i run the above code, the value of 'obj' is printed as 4 irrespective of any link i click in the jsp. Kindly help with a solution.....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Do you really not indent your code? It's unreadable as is.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
Yes very bad indentation...

anyway, you have an iterator object that is assigned to your obj Object as in the code below, and in your servlet you will get the last value in the list assigned in the internal loop.



ofcourse you are writing something wrong here, because in the loop you will keep overwrite the value of the parameter "value" in the session scope and in the end get the last value. if you want to know which link has been clicked you should add an (id) as a parameter in the link for example like this:




By the way I see you are using <%= %> and <% %> tags. try to avoid them as much as possible, and use EL and JSTL instead such as ${obj.id}


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575



session is an one of the implicit object in jsp
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get the value in a jsp page to the servlet