*Manoj - reddy This is a sample Java code repository.
-
check basic explanation of details of file hierarchy structure File-hierachy in this sample java project
-
Please clone it and follow the deployment process mentioned in the Local-3Tier-Deployment
-
You can also explore the wiki pages in the repository for more details of the installations with snapshots.
-
HomeController.java:
- A Spring MVC controller class.
- Contains two request mapping methods:
home()
andDefault()
. - Handles requests to "/home" and "/" URLs.
- Returns a ModelAndView with view names "home" for both URL mappings.
-
login.java:
- Another Spring MVC controller class for user login functionality.
- Uses
@Value
annotations to inject database connection properties. - Contains two request mapping methods:
registerform()
andlogin(String userName, String password)
. - The
registerform()
method handles GET requests to "/login" and returns the "login" view. - The
login(String userName, String password)
method handles POST requests to "/login," validates user credentials in a database, and returns either the "user" view (on successful login) or the "login" view (on failed login).
-
register.java:
- A Spring MVC controller class for user registration functionality.
- Also uses
@Value
annotations to inject database connection properties. - Contains two request mapping methods:
registerform()
andregister(...)
. - The
registerform()
method handles GET requests to "/register" and returns the "register" view for displaying the registration form. - The
register(...)
method handles POST requests to "/register," inserts user data into a database table, and returns the "register" view with a success message.
-
MyWebAppApplication.java:
- The main class for your Spring Boot application.
- Uses the
@SpringBootApplication
annotation to configure and bootstrap the application. - Contains the
main
method that initiates the application and runs it.
-
ServletInitializer.java:
- A class used for configuring your Spring Boot application when deploying it as a WAR file in a Servlet container.
- Extends
SpringBootServletInitializer
. - Overrides the
configure
method to specify the primary configuration class (MyWebAppApplication.class
) for the application context.
-
index.jsp:
- Main homepage displaying a welcome message with the username.
- Includes buttons linking to different sections of the website.
-
login.jsp:
- Page for user login.
- Features a form for entering a username and password.
- Users can submit the form to log in or register as a new user.
-
register.jsp:
- Page for user registration.
- Contains a form for entering user details (first name, last name, email, username, password).
- Users can submit the form to create a new account or return to the login page.
-
home.jsp:
- Sample home page.
- Displays a welcome message with the username.
- Offers buttons to access various sections of the website, including galleries, videos, articles, and more.