Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am usinig Netbeans will create a very simple partially-complete CRUD web application with a text file backend. The web application will allow the user

I am usinig Netbeans

will create a very simple partially-complete CRUD web application with a text file backend. The web application will allow the user to view (read) and edit (update) a note. (Create and delete will not be supported at this time.) A note will consist of a title, contents.

Architecture

Create a new web application called Week04Lab_SimpleNoteKeeper.

Add an empty file to /WEB-INF called note.txt which will be used for storing the note details. Add the following two lines to the file:

This is the title Contents go here

Add two JSPs named viewnote.jsp and editnote.jsp in /WEB-INF.

Add one servlet named NoteServlet.java in the package servlets.

Add one Java Bean named Note.java in the package domain.

The application has one URL ote that is mapped to NoteServlet

Requirements

  1. You must use a JavaBean to populate the view and edit pages.
  2. The JavaBean Note.java must have two strings: one for title and one for contents
  3. The servlet must use doGet() for displaying the form in the view or edit mode.
  4. The servlet must use doPost() for saving the form from the edit mode.
  5. The text file note.txt has exactly two lines. The first line is the title; the second line are the contents.

Hints

  1. Accessing files from a servlet is a bit different than from a Java application. In particular, the path of the file is relative to the project root. Here is some code to help you:

String path = getServletContext().getRealPath("/WEB-INFote.txt");

// to read files BufferedReader br = new BufferedReader(new FileReader(new File(path)));

// to write to a file PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(path, false)));

Do not hardcode any file paths in your project since it would not work on another computer.

The edit link can be written as and the edit parameter can be used to determine which JSP to display

image text in transcribed

image text in transcribed

Screenshots Screenshot when the application starts: Simple Note Keeper View Note Title: This is the title Contents: Contents go here Edit 1 of 3 User clicks edit: Simple Note Keeper Edit Note Title: This is the title Contents go here Contents: Save The edits the title and contents fields and clicks save: The edits the title and contents fields and clicks save: Simple Note Keeper View Note Title: Lab 3 Finished Contents: I finished lab 3. I learned about JavaBeans, JSPS, EL, and servlet routing. Edit Screenshots Screenshot when the application starts: Simple Note Keeper View Note Title: This is the title Contents: Contents go here Edit 1 of 3 User clicks edit: Simple Note Keeper Edit Note Title: This is the title Contents go here Contents: Save The edits the title and contents fields and clicks save: The edits the title and contents fields and clicks save: Simple Note Keeper View Note Title: Lab 3 Finished Contents: I finished lab 3. I learned about JavaBeans, JSPS, EL, and servlet routing. Edit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

Students also viewed these Databases questions