JSP 介绍

来源:互联网 发布:js 0开头数字转字符串 编辑:程序博客网 时间:2024/06/05 17:59

jsp是html代码里嵌入java代码。整个jsp页面最终转换成servlet,实际上被调用的是servlet。用特殊的标记将servlet代码标记出来。


下面是一个简单的jsp文件

<%@page import="java.util.Date"%><html><head><title>Test JSP</title></head><body><h1>Test jsp</h1><ul><li> Current time:<%= new Date() %></li><li>Server:<%=application.getServerInfo() %></li><li>Session ID:<%=session.getId() %></li><li>Parameter:<%=request.getParameter("name") %></li></ul></body></html>



如果在http://localhost:8080/JSPdemo/jspdemo1.jsp后面加上?name=tom,那么输出的内容里面Parameter就不会为null,而是tom了

http://localhost:8080/JSPdemo/jspdemo1.jsp?name=tom

0 0