Get a server running locally to run a Struts app

In summary, the conversation discusses the process of getting a server running locally to run a Java Web app. The speaker suggests copying the code into flat files and compiling it with Ant, but is unsure how to run it. They also mention needing access to servlet.jar and potentially creating a war file for deployment on a web server. The speaker advises starting with a simple JSP application before using a web framework like Struts.
  • #1

DaveC426913

Gold Member
22,396
6,083
I need to get a server running locally so I can run my 'Hello World' Java Web app.

http://benmira.free.fr/en/j2ee/struts1.htm" [Broken] I'm using. Unless I misunderstand, all I really need to do is copy all the code into flat files with the appropriate filenames - and then compile it with Ant.

But how do I run it? At some point I'll need to call http : //localhost:8080/hello/HelloWorld


To compile I'm going to need access to servlet.jar. A search of my drive shows nothing except associated with the Eclipse editor, yet I've got java rle and java sdk installed. I'm obviously missing some component.
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Well if nothing else you should be able to produce a war file. War is like a jar but suited for deploying on a web server. You put the war in the auto-deploy directory of the server, and when the Tomact or whatever Java server you have running it will deploy the web app from the war. Then you can access it. I would advise you to first make a simple JSP(Java Server Pages) appliaction and then go with Struts or some other web framework.
 
  • #3


To get a server running locally, you can follow these steps:

1. Download and install a server software such as Apache Tomcat or Jetty on your computer. These are open-source and widely used for running Java web applications.

2. Once the server is installed, you can create a new project in your preferred IDE (such as Eclipse or IntelliJ) and add the necessary Struts libraries to your project's classpath.

3. Next, create a new web application project and add the necessary Struts configuration files (struts-config.xml, web.xml) to your project.

4. Copy the code from the 'Hello World' Java web app that you mentioned into the appropriate files in your project.

5. Compile your project using Ant or your IDE's build tool.

6. Once your project is compiled successfully, you can deploy it to your server by copying the project's .war file (usually found in the 'target' folder) to the 'webapps' directory of your server.

7. Start your server and access the 'Hello World' app by typing the URL http://localhost:8080/hello/HelloWorld in your browser. Make sure to replace 'hello' with the name of your project and 'HelloWorld' with the name of your Java class.

To access the servlet.jar file, you can download it from the Apache Tomcat website or find it in the 'lib' folder of your Tomcat installation directory. You can then add it to your project's classpath.

I hope this helps you get your Struts app running locally. If you encounter any issues, you can refer to the official documentation of the server software you are using or seek help from online forums or communities.
 

1. What is a server and why do I need one to run a Struts app?

A server is a computer or program that provides services or resources to other computers or programs, often over a network. In the context of running a Struts app, a server is needed to host the application and handle requests from clients. This allows the app to be accessed and used by multiple users simultaneously.

2. How do I choose which server to use for my Struts app?

There are many different types of servers available, each with their own advantages and disadvantages. The best server for your Struts app will depend on your specific needs and preferences. Some popular options for Java web applications like Struts include Apache Tomcat, Jetty, and GlassFish.

3. Can I run a Struts app locally without accessing the internet?

Yes, you can run a Struts app locally on your computer without an internet connection. This is known as running the app in a development or testing environment. However, if your app requires access to external resources or databases, you will need an internet connection to access them.

4. How do I set up a local server for my Struts app?

The steps for setting up a local server for your Struts app will depend on the specific server you are using. Generally, you will need to download and install the server software, configure it to run the app, and then start the server. You may also need to configure your app's database and other dependencies to work with the server.

5. Are there any alternatives to running a local server for my Struts app?

Yes, there are alternative options for running a Struts app without a local server. For example, you could use a cloud-based platform like Heroku or Amazon Web Services to host and run your app. However, setting up and managing a local server is often the most cost-effective and customizable option for running a Struts app.

Suggested for: Get a server running locally to run a Struts app

Replies
3
Views
791
Replies
27
Views
269
Replies
8
Views
718
Replies
1
Views
714
Replies
27
Views
3K
Replies
7
Views
1K
Back
Top