1

I am new to Web Development and JAVA , so sorry if the answer to the questions seems pretty obvious.I am building a website using JAVA backend. For the frontend part I want to work with HTML,CSS and JavaScript and for the backend part I have read that I can build that using something called Spring Boot.Now, I want to know is there anyway I can serve the frontend pages(HTML/CSS/Javascript) using JAVA ? I used to do the same using express in NodeJS but I am pretty clueless on how to do this in JAVA ?

2

3 Answers 3

4

for plain html/css/js, just paste all contents under src/main/resources/static folder of spring boot app eg: if you create index.html, keep it in static folder, start springboot app, access http://localhost:8080/index.html, app will be running.

for angular/react apps, you need to use node in development phase, once its prod ready use ng build --prod, paste all contents of dist folder in static folder, it will work.

Hope it helps. sample project https://github.com/souvikbachhar/HotelBooking_Hackerearth

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the classes available in java EE platform to build an back application that handles http request (that kind of class is called controller). Then you can invoke your model classes, and connection to a database thanks to java JPA API. Java EE is usually implemented following the MVC pattern. That patter is a bit old an have a series of disadvantages. Nowadays people use a java framework called spring (Spring boot is a utility that allows you to setup your spring project more easily). This one is usually used with Hibernate (helps you handling O/R mapping and DB connections) and template engine (Like thymeleaf) that allows you to render dinamic html.

Comments

0

use jdk.nashorn.internal package ,documentation for java 8

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.