jsp调用javabean实例
	
    
    
	goodsbean.java
package sale;
public class goodsbean{
    String Product;
    double Price;
    public goodsbean (){
    this.Product = "box";
    this.Price = 5.0;
    }
public void setProduct (String ProductName){
    this.Product = ProductName;
} 
public String getProduct(){
    return (this.Product);
}
public void setPrice (double priceValue){
    this.Price = priceValue;
}
public double getPrice(){
    return (this.Price);
}
}
编译完生成的.class文件,放到:Tomcat 5.5\webapps\ROOT\WEB-INF\classes\sale 目录下。
调用方法:
<%@ page contentType="text/html;charset=GB2312"%> 
<%//request.setCharacterEncoding("iso_8859_1");%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>goodsbean</title>
</head>
<body>
<jsp:useBean id="goodsbean" scope="application" class="sale.goodsbean" />
<%
goodsbean.setProduct("clock");
goodsbean.setPrice(17);
%>
使用方法1:
产品:<%= goodsbean.getProduct()%><br>
税率:<%= goodsbean.getPrice()%>
<%goodsbean.setProduct("chair");
goodsbean.setPrice(3);
%>
<br>使用方法2:
产品:<jsp:getProperty name="goodsbean" property = "Product" />
<br>
税率:<jsp:getProperty name="goodsbean" property = "Price" />
</body>
</html>
注意:设置bean的属性如下
<jsp:setProperty name="goodsbean" property = "Product"   value="asdf"/>
<jsp:setProperty name="goodsbean" property = "Price" value="adad" />
    
     
	
	
    
    
	相关文档:
        
    
    
<%@ page info="Random Image Show"  
    pageEncoding="UTF-8" contentType="image/jpg"  
    autoFlush="true" buffer="16kb" session="false" import="java.io.FileInputStream"  
%>< ......
	
    
        
    
    JSP/Servlet转发与重定向的区别
尽管HttpServletResponse.sendRedirect 方法和RequestDispatcher.forward 方法都可以让浏览器获得另外一个URL所指向的资源,但两者的内部运行机制有着很大的区别。 
  
  下面是HttpServletResponse.sendRedirect 方法实现的请求重定向与RequestDispatcher.forward 方法实现的请求 ......
	
    
        
    
    JSP页面中一般有两类注释
1.html注释
形如<!--...................-->
它会同html标记一同发到客户端
2.jsp注释(3种)
形如<%--.............................--%>
它不会被发送到客户端,只用来注释服务器端的jsp文件,连jsp生成的servlet也没有注释进去,这也是大部分人使用的注释
形如<%//...... ......
	
    
        
    
    jsp中include的两种形式:      1.<%@ include file=” ”%>
                                 &nbs ......
	
    
        
    
    从网上查找资料java/jsp获得客户端(IE)网卡MAC地址的方法大概有三种。
1、通过命令方式,在客户端执行Ipconfig 等等
2、通过ActiveX的方法
3、通过向137的端口发送查询指令的方法
简介:
第一种方法,在真正用到时候不知道为什么获得mac地址的指令阻塞了,不往下继续执行。而且速度是这三种方法中最慢的一种。
代码如下 ......