You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Java开发用的Eclipse(含Photon版)中开发JSP网站?

How to Add JSP Development Support to Eclipse Photon (Pure Java Edition)

Hey there! Since you're already using Eclipse Photon for pure Java work, adding JSP support is straightforward—no need to switch to a different IDE. Let's walk through the steps to get you set up:

Step 1: Install the Eclipse Web Tools Platform (WTP) Plugin

Your pure Java Eclipse Photon doesn't include web development tools out of the box, so we'll install the WTP plugin first:

  • Open Eclipse, go to Help > Install New Software.
  • In the "Work with" dropdown, select the Photon official update site (it’ll look like Photon - https://download.eclipse.org/releases/photon; if it’s not listed, paste that URL directly).
  • Expand the Web, XML, Java EE and OSGi Enterprise Development category.
  • Check these core components (you can pick more if you need extra features, but these are the essentials for JSP):
    • Eclipse Java EE Developer Tools
    • Eclipse Web Developer Tools
    • JSP Development Tools
  • Click Next, review the installation details, accept the license agreements, and proceed.
  • Restart Eclipse when prompted—this is crucial for the changes to take effect.

Step 2: Create a Dynamic Web Project

With the web tools installed, create a project tailored for JSP development:

  • Go to File > New > Project, search for and select Dynamic Web Project.
  • Enter a project name, then click Next.
  • On the next screen, you’ll need a Target Runtime (your web server, like Apache Tomcat). If you haven’t set one up yet, click New Runtime (we’ll cover that in Step 3).
  • Keep most default settings, but if you need a traditional web.xml deployment descriptor, make sure to check that box before clicking Finish.

Step 3: Configure a Web Server (e.g., Apache Tomcat)

To run your JSP project, you need a web server configured in Eclipse:

  • Go to Window > Show View > Servers (if the Servers view is missing, switch to the Java EE perspective via Window > Perspective > Open Perspective > Other > Java EE).
  • Click the link that says No servers are available. Click this link to create a new server....
  • Select Apache > Tomcat v8.5 Server (or v9.0, which works perfectly with Eclipse Photon) and click Next.
  • Browse to your local Tomcat installation directory, then click Finish.
  • Add your project to the server: Right-click the server in the Servers view > Add and Remove..., select your Dynamic Web Project, and click Finish.

Step 4: Create and Edit JSP Files

Now you’re ready to write JSP code:

  • In your project, navigate to the WebContent folder (this is the root of your web app).
  • Right-click WebContent > New > JSP File.
  • Enter a filename (e.g., index.jsp) and click Finish.
  • You can now mix HTML markup with Java code using JSP syntax. Here’s a quick example to get started:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My First JSP</title>
</head>
<body>
    <h1>Hello from JSP!</h1>
    <% String dynamicMessage = "This comes from embedded Java code"; %>
    <p><%= dynamicMessage %></p>
</body>
</html>

Step 5: Run Your JSP Project

Test your application with these steps:

  • Right-click your Dynamic Web Project > Run As > Run on Server.
  • Select your configured Tomcat server and click Finish.
  • Eclipse will start the server and open a browser window pointing to your app (usually at http://localhost:8080/YourProjectName/index.jsp).

Quick Tips

  • Stick to Tomcat 8.5 or 9.0 for the best compatibility with Eclipse Photon.
  • If plugin installation fails, double-check your internet connection and ensure you’re using the correct Photon update site.
  • The Java EE perspective organizes views like Servers and Project Explorer to make web development smoother.

内容的提问来源于stack exchange,提问作者Joel J Sebastian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:58:41