Java 如何运行一个jsp程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20373223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 01:26:50  来源:igfitidea点击:

How to run a jsp program?

javajsp

提问by user2893698

This is a simple jsp program.can anyone tell me the steps to run it?

这是一个简单的jsp程序。谁能告诉我运行它的步骤?

<%-- 
Document   : helloworld
Created on : Dec 20, 2010, 10:20:48 PM
Author     : eswar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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 Page</title>
</head>
<body>

    <p> Hi, <h3><%="Hello!" %></h3></p>
    <p>You successfully run a simple jsp program.</p>
    <p>Learn More concept about jsp.</p>

</body>
</html>

回答by pappu_kutty

you need to have jsp container to execute you jsp files. you can use Tomcat(has jsp container in it) to run your jsp.

你需要有jsp容器来执行你的jsp文件。您可以使用Tomcat(其中包含jsp 容器)来运行您的jsp。

回答by Saif Asif

You need a JSP/Serlvet container that can server JSP pages for you. There a number of JSP/Servlet containers available and used but the most commonly used is Apache Tomcat.

您需要一个可以为您提供 JSP 页面的 JSP/Serlvet 容器。有许多 JSP/Servlet 容器可用和使用,但最常用的是Apache Tomcat

To setup Tomcat,

要设置 Tomcat,

  1. simply download it and extract it into any folder
  2. Next, place your application inside the webapps folder
  3. Start the server.
  4. Open your browser and browse to URL http://localhost:8080, it should open the tomcat's default page
  5. Package your application as war, and place it in the webapps folder of tomcat
  6. Now Access the URL http://localhost:8080/YourApplicatioContext/path/to/jspFileand you will see your JSP file being compiled and served in the browser
  1. 只需下载它并将其解压缩到任何文件夹中
  2. 接下来,将您的应用程序放在 webapps 文件夹中
  3. 启动服务器。
  4. 打开浏览器并浏览到 URL http://localhost:8080,它应该打开 tomcat 的默认页面
  5. 将你的应用打包成war,放到tomcat的webapps文件夹中
  6. 现在访问 URL http://localhost:8080/YourApplicatioContext/path/to/jspFile,您将看到您的 JSP 文件正在编译并在浏览器中提供

回答by uttsav

You need servlet container, connector component and the JSP engine to run JSP pages.In case of tomcat, Catalina is actually the servlet container. Coyote is the connector that handles the requests and forwards them onto Catalina. Web Pages are then delivered dynamically through Jasper, the JSP engine.

您需要 servlet 容器、连接器组件和 JSP 引擎来运行 JSP 页面。在 tomcat 的情况下,Catalina 实际上是 servlet 容器。Coyote 是处理请求并将它们转发到 Catalina 的连接器。然后通过 JSP 引擎 Jasper 动态传送网页。