开发者

Passing parameters from servlet to servlet using HTTP POST

开发者 https://www.devze.com 2023-01-22 08:31 出处:网络
How do I pass parameters from ServletOne to ServletTwo using 开发者_如何学Ca HTTP POST through URL intead of using HTTP GET in the servlet?

How do I pass parameters from ServletOne to ServletTwo using 开发者_如何学Ca HTTP POST through URL intead of using HTTP GET in the servlet?

For example: http://localhost/ServletOne?username=test

If the above link is accessed, in ServletTwo, username test will be displayed.


You've a problem in your class design. The ServletTwo has apparently some code which needs to be reused in ServletOne. You need to refactor that code into a separate Java class. Once done that, all you need to do is to just import/use that Java class in both servlet classes the usual Java way.

0

精彩评论

暂无评论...
验证码 换一张
取 消