JavaScript &JSP [英] JavaScript & JSP

查看:30
本文介绍了JavaScript &JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我已经完成了我的研究并且已经知道 JavaScript = 客户端 JSP = 服务器端.我不想浪费你的时间.

Firstly, I have done my research and already know that JavaScript = client JSPs = server side. I don't want to waste your time.

我的情况是我想从一个事件(而不是一个 HTML 表单)中执行 JSP 代码.

My situation is that I want to execute JSP code from an event (not from a HTML form).

我有一个 HTML 链接(XXX),它不在

中代码>标签;它只是一个普通的 HTML 链接.通过 Javascript,我将能够获取 href 值并将其存储在隐藏的输入字段中.在此之后,我想立即执行 request.getAttribute("...") 并在 JSP 页面之间传递参数.

I have a HTML link (<a href="...">XXX</a>), which is NOT within <form> tags; it just an ordinary HTML link. Through Javascript, I will be able to get the href value and store it in a hidden input field. Instantly after this, I want to execute request.getAttribute("...") and pass the parameter between JSP pages.

我现在知道如何做后面的部分(即让 request.getAttribute 代码在 Javascript 代码执行后立即继续.

I do now know how to do the latter part (i.e. getting the request.getAttribute code to instantly proceed after the Javascript code has executed.

谁能给点建议?

推荐答案

你不能像这样运行 JSP 代码.

You can't run JSP code like this.

JSP 代码,如您所说,是在服务器端运行的,因此您无法真正从 Web 浏览器触发它.

JSP code, as you said is run on the server side, so you can't really trigger it from the web browser.

如果您只是想在 JSP 页面之间传递参数,则可以在调用第二个 JSP 时将该参数添加到 URL 的 queryString 中,并在其中使用 request.getAttribute().

If you are just trying to pass a parameter between JSP pages, you can add the parameter to the queryString of the URL when you call the second JSP, and within it use request.getAttribute().

记住,JSP 代码是在页面发送到浏览器之前执行的.

Remember, JSP code is executed before the page is sent to the browser.

我希望这会有所帮助.

这篇关于JavaScript &amp;JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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