├── NoteTaker
├── pom.xml
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ ├── entities
│ │ │ └── Note.java
│ │ │ ├── helper
│ │ │ └── FactoryProvider.java
│ │ │ └── servlets
│ │ │ ├── DeleteServlet.java
│ │ │ ├── SaveNoteServlet.java
│ │ │ └── UpdateServlet.java
│ │ ├── resources
│ │ └── hibernate.cfg.xml
│ │ └── webapp
│ │ ├── WEB-INF
│ │ └── web.xml
│ │ ├── add_note.jsp
│ │ ├── all_notes.jsp
│ │ ├── alljs_css.jsp
│ │ ├── css
│ │ └── style.css
│ │ ├── edit.jsp
│ │ ├── image
│ │ └── post-it.png
│ │ ├── index.jsp
│ │ └── navbar.jsp
└── target
│ ├── classes
│ ├── com
│ │ ├── entities
│ │ │ └── Note.class
│ │ ├── helper
│ │ │ └── FactoryProvider.class
│ │ └── servlets
│ │ │ ├── DeleteServlet.class
│ │ │ ├── SaveNoteServlet.class
│ │ │ └── UpdateServlet.class
│ └── hibernate.cfg.xml
│ └── m2e-wtp
│ └── web-resources
│ └── META-INF
│ ├── MANIFEST.MF
│ └── maven
│ └── com.todo
│ └── NoteTaker
│ ├── pom.properties
│ └── pom.xml
└── README.md
/NoteTaker/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | com.todo
6 | NoteTaker
7 | war
8 | 0.0.1-SNAPSHOT
9 | NoteTaker Maven Webapp
10 | http://maven.apache.org
11 |
12 |
13 | junit
14 | junit
15 | 3.8.1
16 | test
17 |
18 |
19 |
20 | org.hibernate
21 | hibernate-core
22 | 5.4.12.Final
23 |
24 |
25 |
26 |
27 | mysql
28 | mysql-connector-java
29 | 8.0.22
30 |
31 |
32 |
33 | NoteTaker
34 |
35 |
36 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/java/com/entities/Note.java:
--------------------------------------------------------------------------------
1 | package com.entities;
2 |
3 | import java.util.Date;
4 | import java.util.Random;
5 |
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.Id;
9 |
10 | @Entity
11 | public class Note
12 | {
13 | @Id
14 | private int id;
15 | private String title;
16 | @Column(length=1500)
17 | private String content;
18 | private Date addedDate;
19 | public int getId() {
20 | return id;
21 | }
22 | public void setId(int id) {
23 | this.id = id;
24 | }
25 | public String getTitle() {
26 | return title;
27 | }
28 | public void setTitle(String title) {
29 | this.title = title;
30 | }
31 | public String getContent() {
32 | return content;
33 | }
34 | public void setContent(String content) {
35 | this.content = content;
36 | }
37 | public Date getAddedDate() {
38 | return addedDate;
39 | }
40 | public void setAddedDate(Date addedDate) {
41 | this.addedDate = addedDate;
42 | }
43 | public Note( String title, String content, Date addedDate) {
44 | super();
45 | this.id = new Random().nextInt(10000);
46 | this.title = title;
47 | this.content = content;
48 | this.addedDate = addedDate;
49 | }
50 | public Note() {
51 | super();
52 | // TODO Auto-generated constructor stub
53 | }
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/java/com/helper/FactoryProvider.java:
--------------------------------------------------------------------------------
1 | package com.helper;
2 |
3 | import org.hibernate.SessionFactory;
4 | import org.hibernate.cfg.Configuration;
5 |
6 | public class FactoryProvider
7 | {
8 | public static SessionFactory factory;
9 | public static SessionFactory getFactory()
10 | {
11 | if(factory==null)
12 | {
13 | factory=new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
14 | }
15 | return factory;
16 | }
17 | public void closeFactory()
18 | {
19 | if(factory.isOpen())
20 | {
21 | factory.close();
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/java/com/servlets/DeleteServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlets;
2 |
3 | import java.io.IOException;
4 | import javax.servlet.ServletException;
5 | import javax.servlet.http.HttpServlet;
6 | import javax.servlet.http.HttpServletRequest;
7 | import javax.servlet.http.HttpServletResponse;
8 |
9 | import org.hibernate.Session;
10 | import org.hibernate.Transaction;
11 |
12 | import com.entities.Note;
13 | import com.helper.FactoryProvider;
14 |
15 | /**
16 | * Servlet implementation class DeleteServlet
17 | */
18 | public class DeleteServlet extends HttpServlet {
19 | private static final long serialVersionUID = 1L;
20 |
21 | /**
22 | * @see HttpServlet#HttpServlet()
23 | */
24 | public DeleteServlet() {
25 | super();
26 | // TODO Auto-generated constructor stub
27 | }
28 |
29 | /**
30 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
31 | */
32 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
33 | try {
34 |
35 | int noteId=Integer.parseInt(request.getParameter("note_id").trim());
36 | Session s=FactoryProvider.getFactory().openSession();
37 | Transaction tx=s.beginTransaction();
38 | Note note=(Note)s.get(Note.class, noteId);
39 | s.delete(note);
40 | tx.commit();
41 | s.close();
42 |
43 | response.sendRedirect("all_notes.jsp");
44 | } catch (Exception e) {
45 | // TODO: handle exception
46 | }
47 | }
48 |
49 | /**
50 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
51 | */
52 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
53 | // TODO Auto-generated method stub
54 | doGet(request, response);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/java/com/servlets/SaveNoteServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlets;
2 |
3 | import java.io.IOException;
4 | import java.io.PrintWriter;
5 | import java.util.Date;
6 |
7 | import javax.servlet.ServletException;
8 | import javax.servlet.http.HttpServlet;
9 | import javax.servlet.http.HttpServletRequest;
10 | import javax.servlet.http.HttpServletResponse;
11 |
12 | import org.hibernate.Session;
13 | import org.hibernate.Transaction;
14 |
15 | import com.entities.Note;
16 | import com.helper.FactoryProvider;
17 | public class SaveNoteServlet extends HttpServlet {
18 | private static final long serialVersionUID = 1L;
19 |
20 | /**
21 | * @see HttpServlet#HttpServlet()
22 | */
23 | public SaveNoteServlet() {
24 | super();
25 | // TODO Auto-generated constructor stub
26 | }
27 |
28 | /**
29 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
30 | */
31 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
32 | // TODO Auto-generated method stub
33 | response.getWriter().append("Served at: ").append(request.getContextPath());
34 | }
35 |
36 | /**
37 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
38 | */
39 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
40 | try {
41 | String title=request.getParameter("title");
42 | String content=request.getParameter("content");
43 | Note note=new Note(title, content,new Date());
44 | Session s=FactoryProvider.getFactory().openSession();
45 | Transaction tx=s.beginTransaction();
46 | s.save(note);
47 | tx.commit();
48 | s.close();
49 | response.setContentType("text/html");
50 | PrintWriter out=response.getWriter();
51 | out.println("
Note is added Successfully
");
52 | out.println("");
53 | } catch (Exception e) {
54 | e.printStackTrace();
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/java/com/servlets/UpdateServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlets;
2 |
3 | import java.io.IOException;
4 | import java.util.Date;
5 |
6 | import javax.servlet.ServletException;
7 | import javax.servlet.http.HttpServlet;
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpServletResponse;
10 |
11 | import org.hibernate.Session;
12 | import org.hibernate.Transaction;
13 |
14 | import com.entities.Note;
15 | import com.helper.FactoryProvider;
16 |
17 | /**
18 | * Servlet implementation class UpdateServlet
19 | */
20 | public class UpdateServlet extends HttpServlet {
21 | private static final long serialVersionUID = 1L;
22 |
23 | /**
24 | * @see HttpServlet#HttpServlet()
25 | */
26 | public UpdateServlet() {
27 | super();
28 | // TODO Auto-generated constructor stub
29 | }
30 |
31 | /**
32 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
33 | */
34 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
35 | // TODO Auto-generated method stub
36 | response.getWriter().append("Served at: ").append(request.getContextPath());
37 | }
38 |
39 | /**
40 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
41 | */
42 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
43 | try {
44 | String title=request.getParameter("title");
45 | String content=request.getParameter("content");
46 | int noteId=Integer.parseInt(request.getParameter("noteId").trim());
47 | Session s=FactoryProvider.getFactory().openSession();
48 | Transaction tx=s.beginTransaction();
49 | Note note=s.get(Note.class,noteId);
50 | note.setTitle(title);
51 | note.setContent(content);
52 | note.setAddedDate(new Date());
53 | tx.commit();
54 | s.close();
55 | response.sendRedirect("all_notes.jsp");
56 |
57 |
58 | } catch (Exception e) {
59 | e.printStackTrace();
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 | com.mysql.jdbc.Driver
8 | jdbc:mysql://localhost:3306/myhiber
9 | root
10 | Chitkara@123
11 | org.hibernate.dialect.MySQL8Dialect
12 | update
13 | true
14 | true
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 | Archetype Created Web Application
8 |
9 | SaveNoteServlet
10 | SaveNoteServlet
11 |
12 | com.servlets.SaveNoteServlet
13 |
14 |
15 | DeleteServlet
16 | DeleteServlet
17 |
18 | com.servlets.DeleteServlet
19 |
20 |
21 | UpdateServlet
22 | UpdateServlet
23 |
24 | com.servlets.UpdateServlet
25 |
26 |
27 | SaveNoteServlet
28 | /SaveNoteServlet
29 |
30 |
31 | DeleteServlet
32 | /DeleteServlet
33 |
34 |
35 | UpdateServlet
36 | /UpdateServlet
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/add_note.jsp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | AddNotes
10 | <%@include file="alljs_css.jsp" %>
11 |
12 |
13 |
14 | <%@include file="navbar.jsp" %>
15 |
16 |
Please fill your details
17 |
18 |
19 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/all_notes.jsp:
--------------------------------------------------------------------------------
1 | <%@page import="java.util.List"%>
2 | <%@page import="org.hibernate.Query"%>
3 | <%@page import="com.helper.FactoryProvider"%>
4 | <%@page import="org.hibernate.Session"%>
5 | <%@page import="com.entities.*" %>
6 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
7 | pageEncoding="ISO-8859-1"%>
8 |
9 |
10 |
11 |
12 | All Notes:Note Taker
13 | <%@include file="alljs_css.jsp" %>
14 |
15 |
16 |
17 | <%@include file="navbar.jsp" %>
18 |
19 |
All notes:
20 |
21 |
22 |
23 | <%
24 |
25 | Session s=FactoryProvider.getFactory().openSession();
26 | Query q=s.createQuery("from Note");
27 | List
list=q.list();
28 | for(Note note:list)
29 | {
30 | %>
31 |
32 |
33 |
34 |
35 |

36 |
37 |
<%=note.getTitle() %>
38 |
<%=note.getContent() %>
39 |
<%=note.getAddedDate() %>
40 |
41 |
Delete
42 |
Update
43 |
44 |
45 |
46 |
47 |
48 | <%
49 | }
50 | s.close();
51 | %>
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/alljs_css.jsp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/css/style.css:
--------------------------------------------------------------------------------
1 | .purple
2 | {
3 | background:#673ab7;
4 | }
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/edit.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@page import ="com.helper.*,org.hibernate.*,com.entities.*" %>
4 |
5 |
6 |
7 |
8 | Insert title here
9 | <%@include file="alljs_css.jsp" %>
10 |
11 |
12 |
13 | <%@include file="navbar.jsp" %>
14 |
15 |
Edit your page
16 |
17 | <%
18 |
19 | int noteId=Integer.parseInt(request.getParameter("note_id").trim());
20 | Session s=FactoryProvider.getFactory().openSession();
21 | Transaction tx=s.beginTransaction();
22 | Note note=(Note)s.get(Note.class, noteId);
23 | %>
24 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/image/post-it.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ashish2030/TodoList/61cde464a52354a4b6c4ad536a74e1a91538af71/NoteTaker/src/main/webapp/image/post-it.png
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Note Taker : Home page
10 | <%@include file="alljs_css.jsp" %>
11 |
12 |
13 |
14 | <%@include file="navbar.jsp" %>
15 |
16 |
17 |

18 |
Start your day Ashish
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/NoteTaker/src/main/webapp/navbar.jsp:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/NoteTaker/target/classes/com/entities/Note.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ashish2030/TodoList/61cde464a52354a4b6c4ad536a74e1a91538af71/NoteTaker/target/classes/com/entities/Note.class
--------------------------------------------------------------------------------
/NoteTaker/target/classes/com/helper/FactoryProvider.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ashish2030/TodoList/61cde464a52354a4b6c4ad536a74e1a91538af71/NoteTaker/target/classes/com/helper/FactoryProvider.class
--------------------------------------------------------------------------------
/NoteTaker/target/classes/com/servlets/DeleteServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ashish2030/TodoList/61cde464a52354a4b6c4ad536a74e1a91538af71/NoteTaker/target/classes/com/servlets/DeleteServlet.class
--------------------------------------------------------------------------------
/NoteTaker/target/classes/com/servlets/SaveNoteServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ashish2030/TodoList/61cde464a52354a4b6c4ad536a74e1a91538af71/NoteTaker/target/classes/com/servlets/SaveNoteServlet.class
--------------------------------------------------------------------------------
/NoteTaker/target/classes/com/servlets/UpdateServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ashish2030/TodoList/61cde464a52354a4b6c4ad536a74e1a91538af71/NoteTaker/target/classes/com/servlets/UpdateServlet.class
--------------------------------------------------------------------------------
/NoteTaker/target/classes/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 | com.mysql.jdbc.Driver
8 | jdbc:mysql://localhost:3306/myhiber
9 | root
10 | Chitkara@123
11 | org.hibernate.dialect.MySQL8Dialect
12 | update
13 | true
14 | true
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/NoteTaker/target/m2e-wtp/web-resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Built-By: Ashish
3 | Build-Jdk: 15.0.1
4 | Created-By: Maven Integration for Eclipse
5 |
6 |
--------------------------------------------------------------------------------
/NoteTaker/target/m2e-wtp/web-resources/META-INF/maven/com.todo/NoteTaker/pom.properties:
--------------------------------------------------------------------------------
1 | #Generated by Maven Integration for Eclipse
2 | #Mon Nov 30 11:38:01 IST 2020
3 | m2e.projectLocation=C\:\\Users\\Ashish\\ashish\\NoteTaker
4 | m2e.projectName=NoteTaker
5 | groupId=com.todo
6 | artifactId=NoteTaker
7 | version=0.0.1-SNAPSHOT
8 |
--------------------------------------------------------------------------------
/NoteTaker/target/m2e-wtp/web-resources/META-INF/maven/com.todo/NoteTaker/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | com.todo
6 | NoteTaker
7 | war
8 | 0.0.1-SNAPSHOT
9 | NoteTaker Maven Webapp
10 | http://maven.apache.org
11 |
12 |
13 | junit
14 | junit
15 | 3.8.1
16 | test
17 |
18 |
19 |
20 | org.hibernate
21 | hibernate-core
22 | 5.4.12.Final
23 |
24 |
25 |
26 |
27 | mysql
28 | mysql-connector-java
29 | 8.0.22
30 |
31 |
32 |
33 | NoteTaker
34 |
35 |
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TodoList
--------------------------------------------------------------------------------