如何将String值从一个servlet传递到另一个servlet? [英] How to pass a String value from one servlet to another servlet?
本文介绍了如何将String值从一个servlet传递到另一个servlet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JSP从我使用的request.getParameter我想链接servlet1和servlet2和发送,我在servlet1到servlet2已经拿到了字符串值获得在servlet1一个字符串值。
I have one jsp from which I am getting a string value in servlet1 using 'request.getParameter' I want to link servlet1 and servlet2 and send the string value which i have got in servlet1 to servlet2.
请帮忙。
非常感谢提前。
推荐答案
您需要设置请求属性
在您的servlet1中。
In your servlet1.
request.setAttribute("attributeName",yourStringVAlue);
RequestDispatcher rd = request.getRequestDispatcher("yourServletPattern");
rd.forward(request,response);
在您的Servlet2中
In your Servlet2
String someName = (String)request.getAttribute("attributeName");
这篇关于如何将String值从一个servlet传递到另一个servlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文