• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Embed data in a url and pass it to a servlet

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ??
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cant seem to find any information of restful url ? Could you please explain it a little?
 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Representational State Transfer on Wikipedia
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can send data in url string itsel as follow:
yoururl?key=value&key2=value2
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic