Answers

Question and Answer:

  Home  BEA Weblogic

⟩ 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

}

 217 views

More Questions for you: