Java代码:
package com.java.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Request extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    public Request() {
        super();
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("money", 5000);
        
        //转发到页面
        request.getRequestDispatcher("HTML/index.jsp").forward(request, response);
    }
    
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
JSP代码:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- 引入C标签库 -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP 标准标签库(JSTL)</title>
    </head>
    <body style="text-align: center;">
        <!--
        var:变量名 
        scope:变量的作用域
        value:要储存的值
        -->
        <c:set var="salary" scope="session" value="${2000*2}"/>
        <h1>我的工资是:${ salary }</h1>
        <!-- 
        scope的作用域大小依次为:
        application > session > request > page(默认)
        
        jsp处理变量的作用域先后依次为:
        page(默认) -> request -> session -> application
         -->
         
         <!-- 比较的变量money是从Request转发过来的 -->
        <c:if test="${ salary < money }">
            <h1>我的工资小于5000</h1>
        </c:if>
        
        <h1><a href="http://www.runoob.com/jsp/jsp-jstl.html" target="view_window" style="text-decoration: none; color: red;">查看更多使用方法点我</a></h1>
    </body>
</html>
项目图片:

需要引用的lib里的2个jar包
 
  
  
 