![]() |
![]() |
|
FAQs: Server-Side Java (Servlets)
How do I call a servlet with parameters in the URL?
The usual format of a servlet parameter is a name=value pair that comes after a
question-mark (?) at the end of the URL. To access these parameters, call the
getParameter() method on the HttpServletRequest object, then write code to test
the strings. For example, if your URL parameters are "func=topic," where your URL
appears as:
http://www.myserver.com/myservlet?func=topic
then you could parse the parameter as follows, where "req" is the HttpServletRequest object:
String func = req.getParameter("func");
if (func.equalsIgnoreCase("topic")) {
. . . do some work
}
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|