如题!
解决方案 »
- Solr1.3升级至3.5是需要注意的事项?
- struts2 validation 服务器端验证,提示一些项必输,在填写后在提交到struts 的action不起作用?
- 求助::急急急!!!文本框改变显示问题<input type="text" name="keyWord">
- 求教:集群
- 在actionform中定了一个javabean类数组,在jsp中用iterate显示每个javabean,但在表单提交后action中取不到更新的值
- 高分求助,请问怎样用JSP操纵数据库的表
- eclipse+Lomboz+tomcat配置出现问题了!请教!
- 请问谁做过网络考试系统,遇到难题,请高手指点.....(在线等候)
- 如何将form提交的值同时传给两个.jsp文件。
- jsp的入门问题,希望各位帮忙!
- 求救:中文文件名做链接 老找不到这个文件????
- 紧急求助,清高手指点
往apllication里邦定对象也是 setAttribute()方法?
<%
pageContext.setAttribute("a", "ok");
request.setAttribute("b", "ok");
session.setAttribute("c", "ok");
application.setAttribute("d", "ok");
%>***************************
该jsp页面被转换为Servlet后的java源代码如下:
package org.apache.jsp;import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;public final class a_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent { private static java.util.List _jspx_dependants; public Object getDependants() {
return _jspx_dependants;
} public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException { JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=GBK");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out; out.write("\r\n");
out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n");
out.write("<head>\r\n");
out.write("\t<title>a.jsp</title>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("\t"); pageContext.setAttribute("a", "ok");
request.setAttribute("b", "ok");
session.setAttribute("c", "ok");
application.setAttribute("d", "ok");
out.write("\r\n");
out.write("</body>\r\n");
out.write("</html:html>\r\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
lz现在明白了吧。Servlet中的ServerContext就是jsp中的application对象,
在Servlet中调用:this.getServletContext().setAttribute("aaa", "bbb");即可。