Giter Site home page Giter Site logo

mendboltdemo's Introduction

About this project

This project is a simple demo web application using Java annotations. It runs on Java 7 and requires an application server, such as Glassfish, to run*. The project, built using Maven, will produce a deployable WAR file. It outputs JSON using Google's Gson library, which is imported and bundled at build time.

The annotations used are defined in the JAX-RS API.

*) Well, it actually doesn't. You can just as well embed a Java web container in your project, such as Jetty, and be done with it. Using an application server is probably easier for beginners, though.

How do I build this project?

You can easily build the code directly from within your IDE of choice (I'm personally rather fond of Eclipse), using its build features (in Eclipse, right click the project and select Run As -> Maven build, type package into the Goals field, then Run). If you prefer doing stuff more old school, you can use the command line to build the project as well. To do so, you need to have Maven installed on your machine. Navigate to your project location. Then, simply type

mvn package

in your terminal. Your generated WAR file can be found as ./target/wwp-1.0.0.war.

How do I run this project?

First of all, you'll need an application server. For this guide, I'll assume you've installed Glassfish (for a guide on doing so, please refer to Glassfish's get started guide).

Navigate to Glassfish's directory. Start Glassfish by executing the following command from the command line:

glassfish4/bin/asadmin start-domain

Open a new browser window/tab and type in localhost:4848. Find the Applications link in the menu and click it. Next, click the Deploy button and select ./target/wwp-1.0.0.war. Once done, click the Launch link and you're all set to try your new application. It will be made available at http://localhost:8080/wwp-1.0.0.

How do I configure my application?

The web page

The web application (or servlet in Java lingo) comes with a very simple web page. It is written in JSP, a web language akin to ASP or PHP (although I only use standard HTML in this example). You can put as many JSP pages as you wish in the src/main/webapp/ folder. Static resources, such as CSS files or images, are put in src/main/webapp/static/ and accessed by linking to static/style.css (for an example CSS file).

The application path ALL OK

As you'll see, your application's URL needs to be amended with /webapi/service/ in order to actually do something. This isn't something that is selected at random, but is set in your web.xml file (which you'll find in src/main/webapp/WEB-INF/), as well as in your servlet Java file.

The /webapi/ part is set by the directive in web.xml. The /service/ part is set by altering the argument to the initial @Path annotation in the servlet's source code. In this case, that file is WebService.java, that you'll find in src/main/java/koddas/web/war.

By changing these values and rebuilding (and consequent redeploying) your project, you'll be able to reach your application with your fancy new path. Please note that the links displayed on the web page will not change accordingly, as they are set manually.

mendboltdemo's People

Contributors

ellurukalyan avatar koddas avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.