如何为 Java Servlet 和 JSP 配置 Eclipse

发布于 2024-12-20 12:41:05 字数 81 浏览 1 评论 0原文

我正在做jsp。我有 eclipse 但不知道如何为 servlet 和 jsp 配置它。我想开发和调试我的网络应用程序。我应该从哪里获取哪个插件?

I am working on jsp. I have eclipse but don't know how to configure it for servlets and jsps. I want to develop and debug my web application. Which plugin should I get and from where?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小…楫夜泊 2024-12-27 12:41:05

您应该下载正确的版本,而不是安装插件。

下载:面向 Java EE 开发人员的 Eclipse IDE,212 MB

此版本从 WTP/Web 工具平台插件

我不确定是否包含像 Tomcat 这样的应用程序服务器。否则下载它。

然后将tomcat添加到eclipse。 (还有其他指南,只需谷歌一下即可。)

Instead of installing plugins you should download the right version.

Download: Eclipse IDE for Java EE Developers, 212 MB

This one has the Web Development perspective from the WTP/Web Tools Platform plugin.

I'm not sure if an application server like Tomcat is included. Otherwise download it.

Afterwards add tomcat to eclipse. (There are other guides as well, just google them.)

不必你懂 2024-12-27 12:41:05

你必须安装像 apache 或 glasfish 或 jboss 这样的服务器才能在其上运行 jsp 和 servlet 我建议你下载 oepe eclipse 版本的 oracle

它有一些额外的 eclipse 插件,例如预览 jsp和 html 页面并显示用于 jsf 开发的调色板,并支持 ADF。

you have to install a server like apache or glasfish or jboss to be able to run jsp and servlets on it I suggest you to download the oepe eclipse version of oracle

it has some additional addons to eclipse like previewing jsp and html pages and displaying palette for jsf development and suports ADF its greate.

白昼 2024-12-27 12:41:05

请遵循此分步指南:

注意:我强烈建议您保留教程中所述的文件名称、文件位置和文件夹。


下载 Eclipse 和Java

  1. 下载 Eclipse IDE Luna SR1 Packages 版本(我特别推荐此版本,只是因为我尝试使用下面的 JDK 和 Tomcat 版本设置此版本,并且它有效)

Eclipse:https://www.eclipse.org/downloads/packages /release/luna/sr1
2. 从这里下载 JDK 版本 8u25 版本: https://www.oracle.com/ca-en/java/technologies/javase/javase8-archive-downloads.html

提示:您将在上面的链接中找到一百个版本的 JDK!只需 ctrl + f 并搜索“8u25”。

  1. 从此处下载 Apache Tomcat 版本 8.0.18: https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.18/bin/apache-tomcat-8.0.18-windows-x64.zip

安装与安装设置

  1. 提取下载的 Eclipse .zip 文件并将其保存在您会记住的位置。
  2. 解压下载的Tomcat版本并将解压后的文件夹重命名为Tomcat8.0
  3. 将Tomcat8.0粘贴到本地磁盘C:/
  4. 解压下载的Java JDK文件并使用默认文件安装
    安装位置(C:\Program Files\Java)。
  5. 现在,您必须设置环境变量

以下是如何在Windows 10中设置环境变量。(我假设Win 7/8也是如此)

  1. 打开控制面板>系统与安全>系统>高级系统设置(在右侧面板上)>高级(选项卡)>环境变量..
  2. 在名为“系统变量”的底部部分中,单击新建.. 并使用给定的变量名称和变量值添加 3 个不同的变量设置,如下所示:

注意:如果您在其他地方安装了 JDK 和 Tomcat,则必须在下面的变量值中输入更新位置的完整路径。

对于 JDK

变量名称:JAVA_HOME

变量值:C:\Program Files\Java\jdk1.8.0_25

对于 JRE,添加另一个变量

变量名称:JRE_HOME

变量值:C:\Program Files\Java\jre1.8.0_25

对于 Tomcat,添加另一个 catalina 变量

变量名称:CATALINA_HOME

变量值:C:\Tomcat8.0


设置 Eclipse 进行动态 Web 开发

  1. 从您提取并保存的目录中打开 eclipse.exe

  2. 导航到帮助>安装新软件..

  3. 使用:中输入“http://download.eclipse.org/releases/luna”并按 Enter< /p>

  4. 在“Web、XML、Java EE 和 OSGi”下Enterprise Development”,选择以下选项并安装

    Eclipse Java EE 开发人员工具

    Eclipse Java Web 开发人员工具

    Eclipse Web 开发人员工具

    JST 服务器适配器

    JST 服务器适配器扩展

    JST服务器U

  5. 重新启动 Eclipse安装后出现提示时

现在,您可以在 Eclipse 中创建动态 Web 应用程序!

  1. 转到文件>新的>其他>在网络>下动态Web应用程序

  2. 输入项目名称并单击“下一步”

  3. 您可以将内容目录名称 (WebContent) 更改为您喜欢的任何名称;但在这里,我暂时将其保留为 WebContent

  4. 点击完成

  5. 在项目资源管理器中,右键单击WebContent >新的> JSP 文件 并向其中添加您喜欢的任何内容,然后保存项目。将 JSP 文件命名为“example.jsp”

  6. 打开 eclipse 工作区位置(通常位于C:\Users%YourName%\Documents\Java\WORKSPACE)< /p>

  7. 复制WebContent文件夹并将其粘贴到 C: > Tomcat8.0>>网络应用


在 Apache Tomcat 上运行项目

  • 打开命令提示符 (CMD) 开始 > (输入)CMD >打开
  • 导航到C:/Tomcate8.0/bin/startup.bat并返回[如果您想停止Tomcat运行,则运行shutdown.bat > 与 startup.bat 位于同一目录中]

提示:您可以从 services.msc 运行/停止 Tomcat(开始键 + R > services.msc > Tomcat8.0 > 停止/启动)

  • 现在,转到在浏览器上访问 http://localhost:8080/,您应该会看到 Tomcat 的菜单。
  • 单击右侧面板上的“管理器应用程序”,然后输入Admin作为用户名,并将密码留空。
  • 单击WebContent
  • 您现在应该可以看到在 Eclipse 动态 Web 项目中创建的 example.jsp 文件的内容。
  • 对于 example.jsp 中所做的每项更改,您必须将 WebContent 文件夹从 eclipse 工作区复制并粘贴到 Tomcate > 中。 webapps 文件夹;并重新启动 Apache Tomcat 服务器。

提示:您可以从 services.msc 重新启动 Tomcat(开始键 + R > services.msc > Tomcat8.0 > 停止/启动)

Follow this step-by-step guide:

Note: I strongly recommend you to keep the Name of the files, location of the files and folders as described in the tutorial.


Downloading Eclipse & Java

  1. Download Eclipse IDE Luna SR1 Packages version (I recommend this version specifically only because I have tried setting up this version with following JDK and Tomcat versions below, and it works)

Eclipse: https://www.eclipse.org/downloads/packages/release/luna/sr1
2. Download JDK version 8u25 version from here: https://www.oracle.com/ca-en/java/technologies/javase/javase8-archive-downloads.html

Tip: You will find a hundred versions of JDK in the link above! Just ctrl + f and search "8u25".

  1. Download Apache Tomcat version 8.0.18 from here: https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.18/bin/apache-tomcat-8.0.18-windows-x64.zip

Installation & Set up

  1. Extract downloaded Eclipse .zip file and save it somewhere you'll remember it.
  2. Extract the downloaded Tomcat version and rename the extracted folder to Tomcat8.0
  3. Paste the Tomcat8.0 to local disk C:/
  4. Extract downloaded Java JDK file and install it with default file
    installation location (C:\Program Files\Java).
  5. Now, you have to setup environment variables

Here's how you can setup environment variables in Windows 10. (I assume same goes for Win 7/8)

  1. Open Control Panel > System and Security > System > Advanced System Settings(On the right side panel) > Advanced (Tab) > Environment Variables..
  2. In the bottom section called "System Variables", click New.. and add 3 different variable setups with the given Variable Name and Variable Value as follows:

NOTE: If you installed JDK and Tomcat somewhere else, then you will have to enter the full path of the updated location below in the Variable Values.

For JDK

Variable Name : JAVA_HOME

Variable Value : C:\Program Files\Java\jdk1.8.0_25

For JRE, add another variable

Variable Name : JRE_HOME

Variable Value : C:\Program Files\Java\jre1.8.0_25

For Tomcat, add another catalina variable

Variable Name : CATALINA_HOME

Variable Value : C:\Tomcat8.0


Set up Eclipse for Dynamic Web Development

  1. Open eclipse.exe from the directory you Extracted and Saved it

  2. Navigate to Help > Install New Software..

  3. Enter "http://download.eclipse.org/releases/luna" in Work with: and hit enter

  4. Under "Web, XML, Java EE and OSGi Enterprise Development", select the following options and install them

    Eclipse Java EE Developer Tools

    Eclipse Java Web Developer Tools

    Eclipse Web Developer Tools

    JST Server Adapters

    JST Server Adapters Extensions

    JST Server U

  5. Restart Eclipse when prompted after installation

Now, you can create a Dynamic Web Application in Eclipse!

  1. Go to File > New > Other > under Web > Dynamic Web Application

  2. Enter a project name and click Next

  3. You can change the Content Directory name (WebContent) to whatever name you prefer; but here, I am keeping it as WebContent for now.

  4. Click on Finish

  5. In the Project Explorer, right click on WebContent > New > JSP File and add any content you like to it, and save the Project. Name JSP file to "example.jsp"

  6. Open the eclipse workspace location (usually located at C:\Users%YourName%\Documents\Java\WORKSPACE)

  7. Copy the WebContent folder and paste it into C: > Tomcat8.0 > webapps


Running the Project on Apache Tomcat

  • Open Command Prompt (CMD) Start > (type in) CMD > Open
  • Navigate to C:/Tomcate8.0/bin/startup.bat and return it [If you want to stop Tomcat from running, then run shutdown.bat which is located in the same directory as startup.bat]

Tip: You can Run/Stop Tomcat from services.msc (Start key + R > services.msc > Tomcat8.0 > Stop/Start)

  • Now, go to http://localhost:8080/ on your browser and you should see the menu of Tomcat.
  • Click on Manager App on the right side panel and enter Admin as the Username and leave the Password blank.
  • Click on WebContent
  • You should now see the content of your example.jsp file that you created in Eclipse Dynamic Web Project.
  • For every changes made in the example.jsp, you must copy and paste the WebContent folder from eclipse workspace to Tomcate > webapps folder; and restart Apache Tomcat server.

Tip: You can RESTART Tomcat from services.msc (Start key + R > services.msc > Tomcat8.0 > Stop/Start)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文