读取一个jsp传递给另一个的参数 [英] read parameters passed by one jsp to another

查看:250
本文介绍了读取一个jsp传递给另一个的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用HTTP POST方法读取由一个JSP传递给另一个参数的参数.

I want to read parameter passed by one JSP to another using HTTP POST method.

以下是我的两个JSP文件.

One.jsp

<body>
<form action="Two.jsp" method="post">
    <input type="text" value="test value" name="txtOne">
    <input type="submit" value="Submit">
</form>
</body>

Two.jsp

<body>
    <% response.getWriter().println(request.getParameter("txtOne")); %>
</body>

我可以使用scriplet访问 Two.jsp 文件中的参数.
我想避免使用scriplet,因此我正在寻找JavaScriptjQuery解决方案.
到目前为止,我已经搜索并找到了JavaScript解决方案,该解决方案仅读取使用GET方法(query string only)发送的参数.

I can access the parameter in Two.jsp file using scriplet.
I want to avoid scriplet, so I am looking for JavaScript or jQuery solution.
So far I have searched and found JavaScript solution which only reads parameters sent using GET method(query string only).

任何建议将不胜感激.

谢谢.

解决方案: 我能够使用JSTL获得价值:

Solution: I was able to get the value using JSTL:

${param.txtOne}

推荐答案

我想避免出现scriplet,因此我正在寻找JavaScript或jquery解决方案.

I want to avoid scriplet, so I am looking for JavaScript or jquery solution.

根本无法.

请求对象只能在服务器端(即您的JSP中)访问.您不能在客户端访问javascript/jquery/whatever.

request object can only accessible on server side, i.e in your JSP. You cannot access request or response object in client side that i.e javascript/jquery/whatever.

如果您要在javascript中访问jsp值,请尝试类似

If you want access jsp value in javascript, try something like

 var news=<%= request.getParameter("txtOne")) %>;

作为旁注:避免scriplets并使用表达式语言.

这篇关于读取一个jsp传递给另一个的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆