Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

What is the behaviour of getParameter for post and get actions?

$
0
0

I have a java servlet with a URL Query string with instructions like this

http://hostname/servet?param1=value1&param2=value2

I also structure the doPost/doGet like this

public void doPost(HttpServletRequest req, HttpServletResponse res) {        try {            doGet(req, res);        } catch (Exception e) {            e.printStackTrace();        }    }public void doGet(HttpServletRequest req, HttpServletResponse res) {        try {            String sParam1 = req.getParameter("param1")        } catch (Exception e) {            e.printStackTrace();        }    }

I can access each queryString parameters via getParameter() for GET actions. But when I attempt to access the same queryString via getParameter() for POST actions, the returned value is NULL.

So, I would like to confirm this behaviour of getParameter for POST and GET actions. That is getParameter does NOT return queryString parameters for POST actions ? And do I need to manually dissect a query string to process them in cases of a POST action ?


Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>