GeeCON Prague 2014*
The moose likes JSP and the fly likes passing parameter from jsp view page tp jsp edit page (crud) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "passing parameter from jsp view page tp jsp edit page (crud)" Watch "passing parameter from jsp view page tp jsp edit page (crud)" New topic
Author

passing parameter from jsp view page tp jsp edit page (crud)

fred kitu
Greenhorn

Joined: Apr 02, 2013
Posts: 5
i can generate users from database to a view page
how do i pass the contact.getID value to a jsp edit page so it can populate that user to allow me to edit

here is my code


displaycontacts.jsp


[/code]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

Firstly, you should be submitting to a servlet, not another JSP, with the id as a request param. The servlet can retrieve the info and forward to the JSP with the data in request scope.

Secondly, putting Java code in a JSP is a bad practice that has been obsolete and discredited for over 12 years.

One of the (very many) good reasons for that is a problem you have in your code that you probably don't even realize: it's not thread safe! As soon as more than one person tries to use your app, it will break, and it will break badly.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
fred kitu
Greenhorn

Joined: Apr 02, 2013
Posts: 5
thanks bear
im just now taking webapp class and i will rem that
do you have a sample servlet code i can refer to?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

Servlet examples will be all over the net!

If you must use Java scriptlets for your class (why scriptlets are being taught 12 years after their obsolescence is beyond me) always avoid using the <%! %> construct. It's nothing but trouble and certainly not needed here.

But if you can eliminate scriptlets entirely, that's even better!
 
jQuery in Action, 2nd edition
 
subject: passing parameter from jsp view page tp jsp edit page (crud)