This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing string to a servlet

 
HARSHAD bhawsar
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frds ,
I have an given link to a string as
<a href=**\myservlet>xyz</a>
after clicking on string 'xyz' a servlet will be called ,I want to pass string 'xyz' to the servlet.
How i should do this?
 
bill bozeman
Ranch Hand
Posts: 1070
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not a servlet expert, but I would imagine that you need to have the link say something like this:
href="servler?someVariable=xyz"
Bill
 
Billy Tsai
Ranch Hand
Posts: 1304
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I want to pass a javascript variable to a servlet using the request scope anyone know how to do it?
like
<script>
function doChange(objName){
//pass the objName to a servlet here using the request scope
//document.location='aServlet' ???
}
</script>

Please help
thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"asdf?blah=" + variable
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using the request scope


You can't. Request scope is a server-side concept and the Javascript executing in the browser has no knowledge of, or access to it. You can pass info to a request via request parameters as Eric has shown.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic