File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "passing string to a servlet" Watch "passing string to a servlet" New topic

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:
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?
function doChange(objName){
//pass the objName to a servlet here using the request scope
//document.location='aServlet' ???

Please help

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

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

Joined: Jan 10, 2002
Posts: 63865

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: passing string to a servlet
It's not a secret anymore!