This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Embed data in a url and pass it to a servlet

 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am currently stuck in a dilemma. I was thinking about an application in which users could add books randomly..
Now when the database is queried it displays all the books present with a hyperlink under the names of the books.When a user clicks on the hyperlink a separate jsp page is loaded with the details of the book.
What i wanted to do was embed the name of a book and its id in the hyperlink and when the servlet runs it extracts the data from the jsp. How could i do that. One way i think would be is to use a hidden input box .. any other recommendations ??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The modern way to do it is with a RESTful URL.

For example: /contextpath/servletpath/books/213

Which would retrieve and display the information for the book with the id of 213.

It's also perfectly acceptable to pass the id as a request parameter in the query string, just not as new wave.
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cant seem to find any information of restful url ? Could you please explain it a little?
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Representational State Transfer on Wikipedia
 
Miku Ranjan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can send data in url string itsel as follow:
yoururl?key=value&key2=value2
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miku Ranjan wrote:Hi,
You can send data in url string itsel as follow:
yoururl?key=value&key2=value2

Yeah, if you want to be "old school".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic