有高手吗?jsp与servlet之间如何共用一个session,为什么我在servlet中得不到jsp里写得session? 要不要cookies支持?session一般是servlet生成、管理... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ page contentType="text/html; charset=GBK" %><%@ page session="true"%><html><head><title>Jsp1</title></head><body><h1>Generated JSPgdfg</h1><form method="get" action="http://localhost:8080/servlet/untitled4.Servlet1" ><br>Enter new value : <input name="sample"><br><br><br><% session.setAttribute("name","test1");%><input type="submit" name="Submit" value="Submit"><input type="reset" value="Reset"><br>Value of Bean property is :</form></body></html>-------------------------------------------------------------------------------- public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(CONTENT_TYPE); HttpSession session = request.getSession(true); PrintWriter out = response.getWriter(); String bb = (String)session.getAttribute("name"); out.println("<html>"); out.println("<head><title>Servlet1</title></head>"); out.println("<body>"); out.println("name is:"+bb); out.println("<p>The servlet has received a GET. This is the reply.</p>"); out.println("</body></html>"); }我用的是tomcat,运行结果是null. java长传问题,输入输出流 高分求助 mybatis一对多查询问题 CSDN首页中的相关联新闻是如何实现的呢? 急!有人知道knime吗?用过的都请进来一下 页面上加div 显示问题(在线等) struct怎么显示嵌套查询的页面 这个有关日期的问题应该不会难住你,来看看吧! 怪怪怪...事还真多.这样的事都有.受不了.................. 请问各位大侠如何在jsp中取得当前框架的名字? 请教:在IBM VisualAge For Java 的 WebSphere测试环境 中测试JSP代码时... 关于JSP的问题!
<%@ page session="true"%>
<html>
<head>
<title>
Jsp1
</title>
</head><body>
<h1>
Generated JSPgdfg
</h1>
<form method="get" action="http://localhost:8080/servlet/untitled4.Servlet1" >
<br>Enter new value : <input name="sample"><br>
<br><br>
<%
session.setAttribute("name","test1");
%>
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="Reset">
<br>
Value of Bean property is :
</form>
</body>
</html>
--------------------------------------------------------------------------------
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
HttpSession session = request.getSession(true);
PrintWriter out = response.getWriter();
String bb = (String)session.getAttribute("name");
out.println("<html>");
out.println("<head><title>Servlet1</title></head>");
out.println("<body>");
out.println("name is:"+bb);
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
}
我用的是tomcat,运行结果是null.