在javabean里不能用session.getValue吗?

sunwatch sunwatch 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
import java.io.*;
public class log_chk
{
String user_id;
void chk_invalue()
{
user_id=(String)session.getValue("user_id");
}
}
编译通不过,提示cannot resolve symbol
symbol :variable session,
location: calss log_chk
user_id=(String)session.getValue("user_id")
好像是user_id=(String)session.getValue("user_id")这句话的错误,
但我在jsp页面里用的好好的阿。
那我在bean里怎么取session里的值呢?
...全文

相关推荐

JSP安全编程实例浅析

JSP安全编程:从脚本编程的角度看JSP的安全,那些诸如源码暴露类的安全隐患就不在这篇文章讨论范围之内了

hduser123

JSP 考试题目一套

一套JSP考试题,填空10题,改错15题,选择10题,编程3题,问答2题。

bijia_2007

struts1-bean标签

Struts Bean标签库中的标签可以访问已存在的JavaBean以及它们的属性,还可以定义新的Bean,把它存放在page范围内或用户指定的范围内,供网页其他元素访问。Bean标签库大概分为三类: 用于访问HTTP请求信息或JSP隐含对象的Bean标签 用于访问Web应用资源的Bean标签 用于定义或者输出JavaBean的Bean标签

JD神

Jsp程序设计试题库

1、jsp的技术特点? 1)将内容的显示与生成进行分离 (2)强调可重用的组件:依赖与可重用的、跨平台的组件来执行应用程序所要求的更为复杂的处理。 (3)采用标识简化页面开发:一次编写,各处运行。 2、jsp有哪些内置对象?作用分别是什么? application对象代表应用程序上下文,它允许JSP页面与包括在同一应用程序中的任何Web组件共享信息。 Out对象代表提供输出流的访问 Page对象代表JSP页面对应的Servlet类实例 Request对象提供对Http请求数据的访问,同时还提供用于加入特定请求数据的上下文 Response对象允许直接访问HttpServletResponse对象 Session对象可能是状态管理上下文中使用最多的对话

zhoussss1

jsp编程关于上传下载设计

<%@ page language="java" import="com.jspsmart.upload.*"%> <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /> <jsp:useBean id="updateBean" scope="page" class="guest.guest" /> <HTML> <BODY BGCOLOR="white"> <H1>jspSmartUpload : Sample 2</H1> <HR> <% String name = (String) session.getValue("username"); // Variables int count=0; // Initialization mySmartUpload.initialize(pageContext); // Upload mySmartUpload.upload(); // Select each file for (int i=0;i<mySmartUpload.getFiles().getCount();i++){ // Retreive the current file com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i); // Save it only if this file exists if (!myFile.isMissing()) { // Save the files with its original names in a virtual path of the web server myFile.saveAs("/upload/" + myFile.getFileName()); // myFile.saveAs("/upload/" + myFile.getFileName(), mySmartUpload.SAVE_VIRTUAL); // sample with a physical path // myFile.saveAs("c:\\temp\\" + myFile.getFileName(), mySmartUpload.SAVE_PHYSICAL); // Display the properties of the current file out.println("FieldName = " + myFile.getFieldName() + "<BR>"); out.println("Size = " + myFile.getSize() + "<BR>"); out.println("FileName = " + myFile.getFileName() + "<BR>"); out.println("FileExt = " + myFile.getFileExt() + "<BR>"); out.println("FilePathName = " + myFile.getFilePathName() + "<BR>"); out.println("ContentType = " + myFile.getContentType() + "<BR>"); out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>"); out.println("TypeMIME = " + myFile.getTypeMIME() + "<BR>"); out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>"); String FileName="../upload/"+myFile.getFileName(); String strSQL="update guestbook set filename='" + FileName + "' where name='"+ name +"'"; updateBean.executeUpdate(strSQL); count ++; } } // Display the number of files which could be uploaded out.println("<BR>" + mySmartUpload.getFiles().getCount() + " files could be uploaded.<BR>"); // Display the number of files uploaded out.println(count + " file(s) uploaded."); %> <% %> </BODY> </HTML>Top

yubohuai
评论 7
收藏 已收藏
分享
返回顶部
sunwatch
Web 开发 81,108 成员 341,721 内容