My recent project involves developing a small login Java program that interacts with servlets and JSPs using the MVC pattern. This program allows users to register and log in to accounts stored in my local MySQL database. To pass values between the servlet and JSP, I am utilizing sessions. Additionally, I have implemented a series of if statements on the servlet for validating inputs.
When running the application, the Sign_Up.jsp page opens displaying fields for UserName and Password along with a submit button. There is also a link to Log_In.jsp in the top left corner. Upon entering valid credentials, an account is created in the database and the user is redirected to Welcome.JSP which simply displays some text. Currently, duplicate entries can be created due to lack of uniqueness validation for usernames and passwords.
If the link on Sign_UP.jsp is clicked, it redirects to Log_In.jsp where users must enter their credentials. If the credentials exist in the database, they are directed to Welcome.jsp; otherwise, an invalid message prompts them to try again.
-----------------------------------MY NEXT GOAL--------------------------------------
After successfully logging in and being redirected to Welcome.jsp, I aim to incorporate a "Choose File" button on the page. This button should enable users to browse their computer for files, specifically selecting a .csv file for parsing and entry into the database. The .csv file may consist of data like:
Username , Password
UserTest1, 123
UserTest2, 234
UserTest3, 567
UserTest4, 890
Here are my questions related to this process:
- Can JavaScript be utilized within a JSP for this task?
- Is it advisable to use JavaScript in a JSP for this purpose?
- For building a more complex website, would it be recommended to incorporate HTML, CSS, and jQuery code directly in the JSP?
The ultimate goal is to create a website where only the admin can upload a .csv file containing prices for items, which will then be uploaded to the database resulting in updated product stock levels. While I understand there is still much work ahead, this marks a promising start. :)