• Post Reply Bookmark Topic Watch Topic
  • New Topic

Making a servlet take arguments

 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have a servlet called searchServlet which takes in a string as an argument. I want to be able to run the servlet by for instance saying:

http://localhost:8080/SearchServlet?searchme=hahaha

My question is about the variable searchme. presumably this should be in my servlet code. How do I define searchme so that I can always run my servlet with searchme as an argument. pls note that searchme will have to be part of the program itself i.e used as an argument within the servlet program . thanks.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use request.getParamter("searchme") to retrieve the value posted.
 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but I get this error

C:\tomcat5\Tomcat 5\webapps\SMSapp\WEB-INF\classes\SearchServlet.java:23: cannot find symbol
symbol : method getParamter(java.lang.String)
location: interface javax.servlet.http.HttpServletRequest

Is there another import statement I have to add?
 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I got it. it was:

import javax.servlet.ServletRequest;
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!