• Post Reply Bookmark Topic Watch Topic
  • New Topic

basic servlet question  RSS feed

 
trupti nigam
Ranch Hand
Posts: 640
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written a servlet where it downloads a file to client machine.
This servlet does not have any JSP.
If I type something like below on the URl the servlet will download the file based on the input paramter in the URL link.

http://localhost:8080/donload marketid=12

I want to know how do I enable to get the marketid = 12 in the servlet?

Is there any thing I need to add in the web.xml?

thanks
Trupti
 
Sri Dharan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get parameters entered in url in servlets

URl => http://localhost:8080/download?marketid=12
HttpServletRequest request;
String mrktId = request.getParameter("marketid");
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does this require? Service method of HttpServlet provides prepared object for HttpServletRequest and HttpServletResponse.

This should be enough.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this require? Service method of HttpServlet provides prepared object for HttpServletRequest and HttpServletResponse.

Don't use the "service" method - use the "doGet" method.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Don't use the "service" method - use the "doGet" method.

Oops! sorry I really missed it and I meant to suggest doGet only.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!