Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
fred kitu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred kitu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic