Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Request Object

 
Shivangi Joshi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to get request object in Servlet If I am not using any HTML or JSP page.So in this case How doGet() will understand what is request coming from browser.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An HTTP request really has nothing to do with an HTML page or a JSP. It can be generated by any number of tools. As long as it conforms to the HTTP rules, a servlet can deal with it just fine.

Perhaps you can add some context to your question?
 
adil qureshi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This way you can handle whether request is a get or post ...

public void doGet(HttpServletRequest request, HttpServletResponse response) {doPost(request,response);}
public void doPost(HttpServletRequest req, HttpServletResponse res) {}

Secondly as you can see that doGet() / doPost() already has the request parameters so you can always get whatever you want from incoming request to the servlet....also can you please discuss in detail what you want to know
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic