jsp 缓存 - 控制,Pragma,Expires,must-revalidate,no-store,no-cache Stuff(force)

缓存 - 控制,Pragma,Expires,must-revalidate,no-store,no-cache Stuff(force)

force-no-cache.jsp
<%-- https://www.mnot.net/cache_docs/ --%>
<%-- http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/ --%>
<%-- http://stackoverflow.com/a/18516720/1260526 --%>
<%-- https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching --%>
<%-- http://stackoverflow.com/questions/18148884/difference-between-no-cache-and-must-revalidate --%>
<%-- http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers --%>


<meta http-equiv="Cache-Control" content="no-store, must-revalidate" />
<%--OPTIONS most badly, see http://stackoverflow.com/a/18516720/1260526 
  no-cache, no-store, must-revalidate, proxy-revalidate, max-age=0, s-max-age=0
--%>
<%--meta http-equiv="Pragma" content="no-cache" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%>
<%--meta http-equiv="Expires" content="0" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%>

<%   
  //response.setDateHeader ("Expires", 0);  (bad, see: http://stackoverflow.com/a/18516720/1260526)
  //response.setHeader("Pragma","no-cache"); (bad, see: http://stackoverflow.com/a/18516720/1260526)
  if (request.getProtocol().equals("HTTP/1.1")){  
   response.setHeader("Cache-Control","no-store, must-revalidate");   
  }
  else {
    response.setHeader("Pragma","no-cache");
	  response.setDateHeader ("Expires", -1);
%>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="expires" content="-1" />
<%     
  }
%>  

jsp 缓存 - 控制,Pragma,Expires,must-revalidate,no-store,no-cache Stuff(force)

缓存 - 控制,Pragma,Expires,must-revalidate,no-store,no-cache Stuff(force)

force-no-cache.jsp
<%-- https://www.mnot.net/cache_docs/ --%>
<%-- http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/ --%>
<%-- http://stackoverflow.com/a/18516720/1260526 --%>
<%-- https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching --%>
<%-- http://stackoverflow.com/questions/18148884/difference-between-no-cache-and-must-revalidate --%>
<%-- http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers --%>


<meta http-equiv="Cache-Control" content="no-store, must-revalidate" />
<%--OPTIONS most badly, see http://stackoverflow.com/a/18516720/1260526 
  no-cache, no-store, must-revalidate, proxy-revalidate, max-age=0, s-max-age=0
--%>
<%--meta http-equiv="Pragma" content="no-cache" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%>
<%--meta http-equiv="Expires" content="0" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%>

<%   
  //response.setDateHeader ("Expires", 0);  (bad, see: http://stackoverflow.com/a/18516720/1260526)
  //response.setHeader("Pragma","no-cache"); (bad, see: http://stackoverflow.com/a/18516720/1260526)
  if (request.getProtocol().equals("HTTP/1.1")){  
   response.setHeader("Cache-Control","no-store, must-revalidate");   
  }
  else {
    response.setHeader("Pragma","no-cache");
	  response.setDateHeader ("Expires", -1);
%>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="expires" content="-1" />
<%     
  }
%>  

jsp 缓存 - 控制,Pragma,Expires,must-revalidate,no-store,no-cache Stuff(force)

缓存 - 控制,Pragma,Expires,must-revalidate,no-store,no-cache Stuff(force)

force-no-cache.jsp
<%-- https://www.mnot.net/cache_docs/ --%>
<%-- http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/ --%>
<%-- http://stackoverflow.com/a/18516720/1260526 --%>
<%-- https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching --%>
<%-- http://stackoverflow.com/questions/18148884/difference-between-no-cache-and-must-revalidate --%>
<%-- http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers --%>


<meta http-equiv="Cache-Control" content="no-store, must-revalidate" />
<%--OPTIONS most badly, see http://stackoverflow.com/a/18516720/1260526 
  no-cache, no-store, must-revalidate, proxy-revalidate, max-age=0, s-max-age=0
--%>
<%--meta http-equiv="Pragma" content="no-cache" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%>
<%--meta http-equiv="Expires" content="0" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%>

<%   
  //response.setDateHeader ("Expires", 0);  (bad, see: http://stackoverflow.com/a/18516720/1260526)
  //response.setHeader("Pragma","no-cache"); (bad, see: http://stackoverflow.com/a/18516720/1260526)
  if (request.getProtocol().equals("HTTP/1.1")){  
   response.setHeader("Cache-Control","no-store, must-revalidate");   
  }
  else {
    response.setHeader("Pragma","no-cache");
	  response.setDateHeader ("Expires", -1);
%>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="expires" content="-1" />
<%     
  }
%>  

jsp actualizar数据

actualizar数据

update datos oracle.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%Class.forName("oracle.jdbc.driver.OracleDriver");%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Actualizar Datos</title>
    </head>
    <body>
        <h3 align="center">Datos Actualizados en la Base de Datos de Oracle</h3>
        <%
            String nombre = request.getParameter("nombre");
            String apellido = request.getParameter("apellido");
            String rutString = request.getParameter("rut");
            int rut = Integer.parseInt(rutString);
            String user = "system";
            String password = "xxxxxxxxxx";
            
            String sql = "update alumno set nombre ='"+nombre+"', apellido = '"+apellido+"'where rut = "+rut+")";
            
            Connection conexion = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE",user,password);
            Statement statement = conexion.createStatement();
            ResultSet tabla = statement.executeQuery(sql);
        %>  
        <table border="0" align="center">
            <tbody>
                <tr>
                    <td><a href="Conexion.jsp">Ver los datos de la Tabla</a></td>
                </tr>
            </tbody>
        </table>

        
    </body>
</html>

jsp creando una conexion a BD oracle y creando una tabla que muestra los datos obtenidos al hacer un select * from tabla

creando una conexion a BD oracle y creando una tabla que muestra los datos obtenidos al hacer un select * from tabla

conexion y datos.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%Class.forName("oracle.jdbc.driver.OracleDriver"); %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Conexion</title>
    </head>
    <body>
        <h3 align="center">Accediendo a la Base de Datos de Oracle desde Jsp</h3>
        <%
            String user = "system";
            String password = "xxxxxxxx";
            String nombre = request.getParameter("nombre");
            Connection conexion = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE",user,password);
            Statement sql = conexion.createStatement();
            ResultSet tabla = sql.executeQuery("select * from alumno");
            //ResultSet tabla = sql.executeQuery("select * from alumno where nombre = '" + nombre + "'");
        %>
        <table border="1" align="center">
            <thead>
                <tr>
                    <th>Nombre</th>
                    <th>Apellido</th>
                    <th>Rut</th>
                </tr>
            </thead>
            <% while(tabla.next()){ %>
            <tbody>
                <tr>
                    <td><%=tabla.getString("nombre")%></td>
                    <td><%=tabla.getString("apellido")%></td>
                    <td><%=tabla.getString("rut")%></td>
                </tr>
            </tbody>
            <% } %>
        </table>

        
    </body>
</html>

jsp Eliminar Datos Oracle

Eliminar Datos Oracle

delete datos.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%Class.forName("oracle.jdbc.driver.OracleDriver");%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Eliminar Datos</title>
    </head>
    <body>
        <h3 align="center">Datos Eliminados de la Base de Datos de Oracle</h3>
        <%
            String rutString = request.getParameter("rut");
            int rut = Integer.parseInt(rutString);
            String user = "system";
            String password = "xxxxxxxx";
            
            String sql = "delete from alumno where rut = "+rut;
            
            Connection conexion = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE",user,password);
            Statement statement = conexion.createStatement();
            ResultSet tabla = statement.executeQuery(sql);
        %>  
        <table border="0" align="center">
            <tbody>
                <tr>
                    <td><a href="Conexion.jsp">Ver los datos de la Tabla</a></td>
                </tr>
            </tbody>
        </table>

        
    </body>
</html>

jsp Insertar Datos和Oracle

Insertar Datos和Oracle

Insertado datos en BD oracle.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%Class.forName("oracle.jdbc.driver.OracleDriver");%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JInsertar Datos</title>
    </head>
    <body>
        <h3 align="center">Datos Insertados en la Base de Datos de Oracle</h3>
        <%
            String nombre = request.getParameter("nombre");
            String apellido = request.getParameter("apellido");
            String rutString = request.getParameter("rut");
            int rut = Integer.parseInt(rutString);
            String user = "system";
            String password = "xxxxxxxx";
            
            String sql = "insert into alumno values('"+nombre+"','"+apellido+"',"+rut+")";
            
            Connection conexion = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE",user,password);
            Statement statement = conexion.createStatement();
            ResultSet tabla = statement.executeQuery(sql);
        %>  
        <table border="0" align="center">
            <tbody>
                <tr>
                    <%//Link para llevar directo a la jsp con los datos de la tabla
                    %>
                    <td><a href="Conexion.jsp">Ver los datos de la Tabla</a></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

jsp FormulariodecálculoFigurasGeométricas。使用HTML和Java计算矩形和圆形区域的数据(基数,高度,辐射

FormulariodecálculoFigurasGeométricas。使用HTML和Java计算矩形和圆的区域,其数据(基数,高度,半径)已通过表单提交。使用Javascript在Canvas上绘制形状。

FigurasGeometricas.jsp
<%-- 
    Document   : index
    Created on : Apr 23, 2015, 5:08:04 PM
    Author     : rurtubiac
--%>

<%@page import="figurasgeometricas.entities.Circle"%>
<%@page import="figurasgeometricas.entities.Rectangle"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
    <!--If code to decide which figure to calculate-->
    
    <% 
        //Java variables to show in HTML
        String ladoa= "0";
        String ladob= "0";
        String areaRectangulo = "0";
        String radio= "0";
        String areaCirculo = "0";
        String informacion = "";
        
        //IFs that look for pressed buttons:
        if (request.getParameter("area_rectangulo")!= null)  {
                figurasgeometricas.entities.Rectangle rectangle = new Rectangle();
                rectangle.setLadoa(Double.valueOf(request.getParameter("ladoa")));
                rectangle.setLadob(Double.valueOf(request.getParameter("ladob")));
                ladoa = String.valueOf(rectangle.getLadoa());
                ladob = String.valueOf(rectangle.getLadob());
                areaRectangulo = String.valueOf(rectangle.calculateRectangle(rectangle.getLadoa(),
                        rectangle.getLadob()));
                informacion = "(Base: "+ladoa+" * Altura: "+ladob+") = Área: "+areaRectangulo;
                figurasgeometricas.entities.Data.rectangle = rectangle;
            }
        if (request.getParameter("area_circulo")!= null) {
                figurasgeometricas.entities.Circle circle = new Circle();
                circle.setRadio(Double.valueOf(request.getParameter("radio")));
                radio = String.valueOf(circle.getRadio());
                areaCirculo= String.valueOf(circle.calculateRadio(circle.getRadio())) ;
                figurasgeometricas.entities.Data.circle = circle;
                informacion = "(Radio: "+radio+ "* 2 * PI) = Área: " + areaCirculo;
            }
    %>
    <!--Dibujos cuadrado-->
    <script>
        //Position parameters used for drawing the figures
        var x = 440;
        var y = 150;
        var width = <%=ladoa%>;
        var height = <%=ladob%>;
        //Create a canvas element
        var canvas = document.createElement('canvas'); 
        //Set canvas width/height                                    
        canvas.style.width='100%';
        canvas.style.height='100%';
        //Set canvas drawing area width/height
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        //Position canvas
        canvas.style.position='absolute';
        canvas.style.left=0;
        canvas.style.top=0;
        canvas.style.zIndex=100000;
        //Make sure you can click 'through' the canvas
        canvas.style.pointerEvents='none'; 
        document.body.appendChild(canvas); 
        //Append canvas to body element
        var context = canvas.getContext('2d');
        //Draw rectangle
        context.rect(x, y, width, height);
        context.lineWidth='1';
        context.strokeStyle='blue';
        context.stroke();
        //Draw circle
        context.beginPath();
        context.arc((<%=radio%>+x), (<%=radio%>+y), <%=radio%>, 0, 2*Math.PI);
        context.stroke();
    </script>
    
    <font face="Verdana">
    <h2>Formulario de cálculo Figuras Geométricas</h2>
    <!--Main Table and Form-->
    <font size="2">
    <form action="index.jsp" method="POST">
        
        <table>
            <tr>
                <td>
                    <!--Cálculos cuadrado-->
                    <table border="0" bgcolor="yellow" width="405">
                    <tbody>
                        <tr bgcolor="red">
                                <td><font color="white">CÁLCULO RECTÁNGULO</td>
                                <td bgcolor="red"></td>
                        </tr>
                        <tr>
                            <td>Ingrese base:</td>
                            <td>
                                <input type="text" name="ladoa" value="<%=ladoa%>"/>
                            </td>
                        </tr>
                        <tr>
                            <td>Ingrese altura:</td>
                            <td>
                                <input type="text" name="ladob" value="<%=ladob%>"/>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <input type="submit" value="Area Rectangulo" name="area_rectangulo" />
                            </td>
                        </tr>
                        <tr>
                            <td>Resultado</td>
                            <td>
                                <input type="text" name="resultado_rectangulo" readonly="readonly" value="<%=areaRectangulo%>"/>
                            </td>
                        </tr>
                    </tbody>
                    </table>
                </td>
                <td>
                    <table bgcolor="white">
                        <tbody>
                            <tr>
                                <td style="vertical-align:top">
                                    <%=informacion%>
                                    
                                </td>
                            </tr>
                            <tr><td><font color="white">.</td></tr>
                            <tr><td><font color="white">.</td></tr>
                            <tr><td><font color="white">.</td></tr>
                            <tr><td><font color="white">.</td></tr>
                        </tbody>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <p></p>
                    <!--Cálculos círculo-->
                    <table bgcolor="yellow" width="405">
                        <tbody >
                            <tr bgcolor="red">
                                <td><font color="white">CÁLCULO CÍRCULO
                                </td>
                                <td bgcolor="red"></td>
                            </tr>
                            <tr>
                                <td>Ingrese radio:</td>
                                <td>
                                    <input type="text" name="radio" value="<%=radio%>" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <input type="submit" value="Area Círculo" name="area_circulo"/>
                                </td>
                            </tr>
                            <tr>
                                <td>Resultado</td>
                                <td>
                                    <input type="text" name="resultado_circulo" readonly="readonly" value="<%=areaCirculo%>"/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
                <td>
                    <!--Dibujos círculo-->
                </td>
            </tr>
        </table>
    </form>
    </font>
    </body>
</html>

jsp 使用JSP,在HTML上运行简单的Java代码。 <br/>浏览器只看到文本的HTML等价物。 <br/> <br/>使用:<br/> * java for loop <br/> * HTML <br/> * JSP sc

使用JSP,在HTML上运行简单的Java代码。 <br/>浏览器只看到文本的HTML等价物。 <br/> <br/>使用:<br/> * java for loop <br/> * HTML <br/> * JSP scriplets <br/> - 评论<% - - %> <br/> - 声明<%%> <br/> - 打印<%=%> <br/> *添加无缓存片段以避免代码缓存。 <br/> <br/>在Netbeans IDE 8.0.2中编码<br/>在Glassfish服务器上运行

PrintForLoop.jsp
<%-- 
    Document   : index
    Created on : Apr 22, 2015, 12:58:57 PM
    Author     : rurtubiac
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%--Prevents from caching--%>
        <% 
            response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 
            response.setHeader("Pragma","no-cache"); //HTTP 1.0 
            response.setDateHeader ("Expires", 0); //prevents caching at the proxy server  
        %>
        <h1>Numbers from 1 to 10</h1>
        <%--Initialization of a Java variable--%>
        <%
            int limit = 10;
        %>
        <%--Uses a java for loop--%>
        <%--We can interrupt the java code with HTML by using the terminator scriptler--%>
        <%
            for (int i = 0; i < limit; i++) {
        %>
        <%--Use of the printing scriptlet--%>
        <%= i+1%>
        <br>
        <%
            }
        %>
    </body>
</html>

jsp JSP页面的头文件,包含有用的taglib和其他内容

JSP页面的头文件,包含有用的taglib和其他内容

_include.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page trimDirectiveWhitespaces="true" %>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<c:set var="contextPath" value="${pageContext.request.contextPath}/"/>