my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes passing string to a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "passing string to a servlet" Watch "passing string to a servlet" New topic
Author

passing string to a servlet

HARSHAD bhawsar
Ranch Hand

Joined: Feb 22, 2001
Posts: 48
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

Joined: Jun 30, 2000
Posts: 1070
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

Joined: May 23, 2003
Posts: 1304
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


BEA 8.1 Certified Administrator, IBM Certified Solution Developer For XML 1.1 and Related Technologies, SCJP, SCWCD, SCBCD, SCDJWS, SCJD, SCEA,
Oracle Certified Master Java EE 5 Enterprise Architect
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
"asdf?blah=" + variable
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing string to a servlet