15158846557 在线咨询 在线咨询
15158846557 在线咨询
所在位置: 首页 > 营销资讯 > 网站运营 > JSP是什么?

JSP是什么?

时间:2023-11-10 07:48:01 | 来源:网站运营

时间:2023-11-10 07:48:01 来源:网站运营

JSP是什么?:如果你了解什么是Servlet,那JSP就很好学了,如果该回答帮助到你,不妨给我点个赞

什么是JSP

JSP全名为Java Server Pages,java服务器页面。JSP是一种基于文本的程序,其特点就是HTML和Java代码共同存在

为什么需要JSP

JSP是为了简化Servlet的工作出现的替代品,Servlet输出HTML非常困难,JSP就是替代Servlet输出HTML的。

简单使用一下JSP

<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>简单使用JSP</title> </head> <body> </body> </html><%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>简单使用JSP</title> </head> <body> <% String s = "HelloWorld"; out.println(s); %> </body> </html>








JSP的工作原理

package org.apache.jsp;import javax.servlet.*;import javax.servlet.http.*;import javax.servlet.jsp.*;import java.util.Date;public final class _1_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory(); private static java.util.List<String> _jspx_dependants; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.List<String> getDependants() { return _jspx_dependants; } public void _jspInit() { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig()); } public void _jspDestroy() { } public void _jspService(final HttpServletRequest request, final HttpServletResponse response) throws java.io.IOException, ServletException { final PageContext pageContext; HttpSession session = null; final ServletContext application; final ServletConfig config; JspWriter out = null; final Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("/r/n"); out.write("/r/n"); out.write("<html>/r/n"); out.write("<head>/r/n"); out.write(" <title>简单使用JSP</title>/r/n"); out.write("</head>/r/n"); out.write("<body>/r/n"); String s = "HelloWorda"; out.println(s); out.write("/r/n"); out.write("</body>/r/n"); out.write("</html>/r/n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }}out.write("/r/n"); out.write("/r/n"); out.write("<html>/r/n"); out.write("<head>/r/n"); out.write(" <title>简单使用JSP</title>/r/n"); out.write("</head>/r/n"); out.write("<body>/r/n");String s = "HelloWorda"; out.println(s);

Servlet+Tomcat

JSP(了解即可)

监听器和过滤器


海量视频资源

在公主号下回复「888」即可获取!!




本已收录至我的GitHub精选文章,欢迎Starhttps://github.com/ZhongFuCheng3y/3y
求点赞 求关注️ 求分享 求留言 对我来说真的 非常有用!!!

收藏等于白嫖,点赞才是真情!

收藏等于白嫖,点赞才是真情!

收藏等于白嫖,点赞才是真情!

关键词:

74
73
25
news

版权所有© 亿企邦 1997-2025 保留一切法律许可权利。

为了最佳展示效果,本站不支持IE9及以下版本的浏览器,建议您使用谷歌Chrome浏览器。 点击下载Chrome浏览器
关闭