Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
- index df5bdd2..0bd119d 100644
- --- a/nbproject/private/private.xml
- +++ b/nbproject/private/private.xml
- @@ -3,11 +3,19 @@
- <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
- <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
- <group>
- - <file>file:/D:/Privat/Klassenmanager/webapp/src/java/beans/School.java</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/src/java/beans/Homework.java</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/src/java/servlets/SchoolClassSwitcher.java</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/web/jsp/klassen.jsp</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/src/java/beans/SchoolClass.java</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/src/java/misc/URLConnection.java</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/src/java/servlets/SiteSwitcher.java</file>
- <file>file:/D:/Privat/Klassenmanager/webapp/web/index.jsp</file>
- <file>file:/D:/Privat/Klassenmanager/webapp/src/java/servlets/LoginServlet.java</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/src/java/misc/BeanFiller.java</file>
- <file>file:/D:/Privat/Klassenmanager/webapp/src/java/beans/Teacher.java</file>
- - <file>file:/D:/Privat/Klassenmanager/webapp/src/java/misc/URLConnection.java</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/web/css/style.css</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/web/jsp/home.jsp</file>
- + <file>file:/D:/Privat/Klassenmanager/webapp/src/java/beans/Event.java</file>
- </group>
- </open-files>
- </project-private>
- diff --git a/src/java/beans/AssigendDate.java b/src/java/beans/AssigendDate.java
- new file mode 100644
- index 0000000..17d757a
- --- /dev/null
- +++ b/src/java/beans/AssigendDate.java
- @@ -0,0 +1,25 @@
- +package beans;
- +
- +import java.sql.Date;
- +
- +public class AssigendDate {
- +
- + private int id;
- + private Date date;
- +
- + public int getId() {
- + return id;
- + }
- +
- + public void setId(int id) {
- + this.id = id;
- + }
- +
- + public Date getDate() {
- + return date;
- + }
- +
- + public void setDate(Date date) {
- + this.date = date;
- + }
- +}
- diff --git a/src/java/beans/Event.java b/src/java/beans/Event.java
- new file mode 100644
- index 0000000..9aea986
- --- /dev/null
- +++ b/src/java/beans/Event.java
- @@ -0,0 +1,49 @@
- +package beans;
- +
- +public class Event {
- + private int id;
- + private String description;
- + private String title;
- + private SchoolClass schoolclass;
- + private SchoolDate schooldate;
- +
- + public int getId() {
- + return id;
- + }
- +
- + public void setId(int id) {
- + this.id = id;
- + }
- +
- + public String getDescription() {
- + return description;
- + }
- +
- + public void setDescription(String description) {
- + this.description = description;
- + }
- +
- + public String getTitle() {
- + return title;
- + }
- +
- + public void setTitle(String title) {
- + this.title = title;
- + }
- +
- + public SchoolClass getSchoolclass() {
- + return schoolclass;
- + }
- +
- + public void setSchoolclass(SchoolClass schoolclass) {
- + this.schoolclass = schoolclass;
- + }
- +
- + public SchoolDate getSchooldate() {
- + return schooldate;
- + }
- +
- + public void setSchooldate(SchoolDate schooldate) {
- + this.schooldate = schooldate;
- + }
- +}
- diff --git a/src/java/beans/Homework.java b/src/java/beans/Homework.java
- new file mode 100644
- index 0000000..dbbb91b
- --- /dev/null
- +++ b/src/java/beans/Homework.java
- @@ -0,0 +1,67 @@
- +package beans;
- +
- +public class Homework {
- + private int id;
- + private String homework;
- + private SchoolClass schoolclass;
- + private Subject subject;
- + private SchoolDate schooldate;
- + private Teacher teacher;
- + private AssigendDate assigenddate;
- +
- + public int getId() {
- + return id;
- + }
- +
- + public void setId(int id) {
- + this.id = id;
- + }
- +
- + public String getHomework() {
- + return homework;
- + }
- +
- + public void setHomework(String homework) {
- + this.homework = homework;
- + }
- +
- + public SchoolClass getSchoolclass() {
- + return schoolclass;
- + }
- +
- + public void setSchoolclass(SchoolClass schoolclass) {
- + this.schoolclass = schoolclass;
- + }
- +
- + public Subject getSubject() {
- + return subject;
- + }
- +
- + public void setSubject(Subject subject) {
- + this.subject = subject;
- + }
- +
- + public SchoolDate getSchooldate() {
- + return schooldate;
- + }
- +
- + public void setSchooldate(SchoolDate schooldate) {
- + this.schooldate = schooldate;
- + }
- +
- + public Teacher getTeacher() {
- + return teacher;
- + }
- +
- + public void setTeacher(Teacher teacher) {
- + this.teacher = teacher;
- + }
- +
- + public AssigendDate getAssigenddate() {
- + return assigenddate;
- + }
- +
- + public void setAssigenddate(AssigendDate assigenddate) {
- + this.assigenddate = assigenddate;
- + }
- +}
- diff --git a/src/java/beans/Pupil.java b/src/java/beans/Pupil.java
- new file mode 100644
- index 0000000..814d1a5
- --- /dev/null
- +++ b/src/java/beans/Pupil.java
- @@ -0,0 +1,78 @@
- +package beans;
- +
- +public class Pupil {
- + private int id;
- + private String password;
- + private String email;
- + private String firstname;
- + private String lastname;
- + private String pupilHash;
- + private boolean activated;
- + private SchoolClass schoolclass;
- +
- + public int getId() {
- + return id;
- + }
- +
- + public void setId(int id) {
- + this.id = id;
- + }
- +
- + public String getPassword() {
- + return password;
- + }
- +
- + public void setPassword(String password) {
- + this.password = password;
- + }
- +
- + public String getEmail() {
- + return email;
- + }
- +
- + public void setEmail(String email) {
- + this.email = email;
- + }
- +
- + public String getFirstname() {
- + return firstname;
- + }
- +
- + public void setFirstname(String firstname) {
- + this.firstname = firstname;
- + }
- +
- + public String getLastname() {
- + return lastname;
- + }
- +
- + public void setLastname(String lastname) {
- + this.lastname = lastname;
- + }
- +
- + public String getPupilHash() {
- + return pupilHash;
- + }
- +
- + public void setPupilHash(String pupilHash) {
- + this.pupilHash = pupilHash;
- + }
- +
- + public boolean isActivated() {
- + return activated;
- + }
- +
- + public void setActivated(boolean activated) {
- + this.activated = activated;
- + }
- +
- + public SchoolClass getSchoolclass() {
- + return schoolclass;
- + }
- +
- + public void setSchoolclass(SchoolClass schoolclass) {
- + this.schoolclass = schoolclass;
- + }
- +
- +
- +}
- diff --git a/src/java/beans/School.java b/src/java/beans/School.java
- index 2b3ae52..6a64bd8 100644
- --- a/src/java/beans/School.java
- +++ b/src/java/beans/School.java
- @@ -1,8 +1,5 @@
- package beans;
- -/**
- - * Created by Matze on 15.07.2017.
- - */
- public class School {
- private int id;
- private String name;
- diff --git a/src/java/beans/SchoolClass.java b/src/java/beans/SchoolClass.java
- new file mode 100644
- index 0000000..dd0540b
- --- /dev/null
- +++ b/src/java/beans/SchoolClass.java
- @@ -0,0 +1,40 @@
- +package beans;
- +
- +public class SchoolClass {
- + private int id;
- + private String name;
- + private School school;
- + private Pupil[] pupil;
- +
- + public int getId() {
- + return id;
- + }
- +
- + public void setId(int id) {
- + this.id = id;
- + }
- +
- + public String getName() {
- + return name;
- + }
- +
- + public void setName(String name) {
- + this.name = name;
- + }
- +
- + public School getSchool() {
- + return school;
- + }
- +
- + public void setSchool(School school) {
- + this.school = school;
- + }
- +
- + public Pupil[] getPupil() {
- + return pupil;
- + }
- +
- + public void setPupil(Pupil[] pupil) {
- + this.pupil = pupil;
- + }
- +}
- diff --git a/src/java/beans/SchoolDate.java b/src/java/beans/SchoolDate.java
- new file mode 100644
- index 0000000..c78d80d
- --- /dev/null
- +++ b/src/java/beans/SchoolDate.java
- @@ -0,0 +1,25 @@
- +package beans;
- +
- +import java.util.Date;
- +
- +
- +public class SchoolDate {
- + private int id;
- + private Date date;
- +
- + public int getId() {
- + return id;
- + }
- +
- + public void setId(int id) {
- + this.id = id;
- + }
- +
- + public Date getDate() {
- + return date;
- + }
- +
- + public void setDate(Date date) {
- + this.date = date;
- + }
- +}
- diff --git a/src/java/beans/Subject.java b/src/java/beans/Subject.java
- new file mode 100644
- index 0000000..c09a63d
- --- /dev/null
- +++ b/src/java/beans/Subject.java
- @@ -0,0 +1,22 @@
- +package beans;
- +
- +public class Subject {
- + private int id;
- + private String subject;
- +
- + public int getId() {
- + return id;
- + }
- +
- + public void setId(int id) {
- + this.id = id;
- + }
- +
- + public String getSubject() {
- + return subject;
- + }
- +
- + public void setSubject(String subject) {
- + this.subject = subject;
- + }
- +}
- diff --git a/src/java/beans/Teacher.java b/src/java/beans/Teacher.java
- index d7be874..973a51c 100644
- --- a/src/java/beans/Teacher.java
- +++ b/src/java/beans/Teacher.java
- @@ -1,8 +1,5 @@
- package beans;
- -/**
- - * Created by Matze on 15.07.2017.
- - */
- public class Teacher {
- private int id;
- private String firstname;
- diff --git a/src/java/beans/User.java b/src/java/beans/User.java
- new file mode 100644
- index 0000000..a25a453
- --- /dev/null
- +++ b/src/java/beans/User.java
- @@ -0,0 +1,19 @@
- +package beans;
- +
- +public class User {
- + private final String type;
- + private final Object object;
- +
- + public User(String type, Object object){
- + this.type = type;
- + this.object = object;
- + }
- +
- + public String getType() {
- + return type;
- + }
- +
- + public Object getObject() {
- + return object;
- + }
- +}
- diff --git a/src/java/misc/BeanChanger.java b/src/java/misc/BeanChanger.java
- new file mode 100644
- index 0000000..3557285
- --- /dev/null
- +++ b/src/java/misc/BeanChanger.java
- @@ -0,0 +1,28 @@
- +package misc;
- +
- +import java.io.IOException;
- +import javax.servlet.http.HttpServletRequest;
- +import javax.servlet.http.HttpServletResponse;
- +import javax.servlet.http.HttpSession;
- +
- +public class BeanChanger {
- +
- + private final HttpServletRequest request;
- + private final HttpServletResponse response;
- + private final HttpSession session;
- + private final URLConnection connection;
- +
- + public BeanChanger(HttpServletRequest request, HttpServletResponse response) {
- + this.response = response;
- + this.request = request;
- + this.session = this.request.getSession();
- + this.connection = new URLConnection();
- + }
- +
- + public void addSchoolClassForTeacher(int schoolClassId, int teacherId) throws IOException{
- + String json = "{schoolclassid: " + schoolClassId + ", teacherid: " + teacherId + "}";
- + String postResponse = connection.post("classgroup", json);
- +
- + //Fehlermeldung einbauen!
- + }
- +}
- diff --git a/src/java/misc/BeanFiller.java b/src/java/misc/BeanFiller.java
- new file mode 100644
- index 0000000..ec11b95
- --- /dev/null
- +++ b/src/java/misc/BeanFiller.java
- @@ -0,0 +1,141 @@
- +package misc;
- +
- +import beans.Event;
- +import beans.Homework;
- +import beans.Pupil;
- +import beans.SchoolClass;
- +import beans.Subject;
- +import beans.Teacher;
- +import beans.User;
- +import com.google.gson.Gson;
- +import com.google.gson.GsonBuilder;
- +import java.io.IOException;
- +import java.util.ArrayList;
- +import java.util.Arrays;
- +import javax.servlet.RequestDispatcher;
- +import javax.servlet.ServletException;
- +import javax.servlet.http.HttpServletRequest;
- +import javax.servlet.http.HttpServletResponse;
- +import javax.servlet.http.HttpSession;
- +
- +public class BeanFiller {
- +
- + private final HttpServletRequest request;
- + private final HttpServletResponse response;
- + private final HttpSession session;
- +
- + public BeanFiller(HttpServletRequest request, HttpServletResponse response) {
- + this.response = response;
- + this.request = request;
- + this.session = this.request.getSession();
- + }
- +
- + public void fillTeacherBeans(String json) throws IOException, ServletException{
- + createTeacherBean(json);
- + User user = (User) this.session.getAttribute("user");
- + Teacher teacher = (Teacher) user.getObject();
- + createSchoolClassBean(teacher.getId());
- + createEventsBeanBySchoolId(teacher.getSchool().getId());
- + createHomeworkBeanByTeacher(teacher.getId());
- + }
- +
- + public void fillChildBeans(String json) throws IOException, ServletException{
- + //String postResponse = checkLogin(json);
- + }
- +
- + public void fillParentBeans(String json) throws IOException, ServletException{
- + //String postResponse = checkLogin(json);
- + }
- +
- + public void fillSchoolAdminBeans(String json) throws IOException, ServletException{
- + // String postResponse = checkLogin(json);
- + }
- +
- + public void fillMinisteriumBeans(String json) throws IOException, ServletException{
- + //String postResponse = checkLogin(json);
- + }
- +
- + public void fail() throws ServletException, IOException{
- + request.getSession().invalidate();
- + RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/home.jsp");
- + dispatcher.forward(request, response);
- + }
- +
- + private void createTeacherBean(String json) throws IOException{
- + URLConnection connection = new URLConnection();
- + String postResponse = connection.post("login", json);
- + Gson g = new GsonBuilder().create();
- + Teacher teacher = g.fromJson(postResponse, Teacher[].class)[0];
- +
- + User user = new User("teacher", teacher);
- + this.session.setAttribute("user", user);
- + }
- +
- + public void createSchoolClassBean(int teacherId) throws IOException{
- + URLConnection connection = new URLConnection();
- + String getResponse = connection.get("schoolclass?teacherid=" + 1); //+ teacherId
- + Gson g = new GsonBuilder().create();
- + SchoolClass[] schoolClass = g.fromJson(getResponse, SchoolClass[].class); //vllt. in eine ArrayList packen, besser in JSP
- +
- + for(SchoolClass school : schoolClass){
- + school.setPupil(createPupilBeanForSchoolClass(school.getId()));
- + }
- +
- + this.session.setAttribute("schoolclass", schoolClass);
- + }
- +
- + public Pupil[] createPupilBeanForSchoolClass(int schoolClassId) throws IOException{
- + URLConnection connection = new URLConnection();
- + String getResponse = connection.get("pupil?schoolclassid=" + schoolClassId);
- + Gson g = new GsonBuilder().create();
- + Pupil[] pupil = g.fromJson(getResponse, Pupil[].class); //vllt. in eine ArrayList packen, besser in JSP
- + return pupil;
- + }
- +
- + public void createSpecificPupilBeanForSchoolClass(int schoolClassId){
- + ArrayList<Pupil> pupilList = new ArrayList<>();
- + SchoolClass[] schoolClass = (SchoolClass[]) this.session.getAttribute("schoolclass");
- + for(SchoolClass school : schoolClass){
- + if(school.getId() == schoolClassId)
- + pupilList.addAll(Arrays.asList(school.getPupil()));
- + }
- + this.session.setAttribute("pupils", pupilList);
- + }
- +
- + public void createHomeworkBeanByTeacher(int teacherId) throws IOException{
- + URLConnection connection = new URLConnection();
- + String getResponse = connection.get("homework?teacherid=" + teacherId);
- + Gson g = new GsonBuilder().create();
- + Homework[] homework = g.fromJson(getResponse, Homework[].class); //vllt. in eine ArrayList packen, besser in JSP
- +
- + this.session.setAttribute("homework", homework);
- + }
- +
- + public void createHomeworkBySchoolClass(int classId) throws IOException{
- + URLConnection connection = new URLConnection();
- + String getResponse = connection.get("homework?classid=" + classId);
- + Gson g = new GsonBuilder().create();
- + Homework[] homework = g.fromJson(getResponse, Homework[].class); //vllt. in eine ArrayList packen, besser in JSP
- +
- + this.session.setAttribute("homework", homework);
- + }
- +
- + public void createSubjectBean() throws IOException{
- + URLConnection connection = new URLConnection();
- + String getResponse = connection.get("subject");
- + Gson g = new GsonBuilder().create();
- + Subject[] subject = g.fromJson(getResponse, Subject[].class); //vllt. in eine ArrayList packen, besser in JSP
- +
- + this.session.setAttribute("subject", subject);
- + }
- +
- + public void createEventsBeanBySchoolId(int schoolId) throws IOException{
- + URLConnection connection = new URLConnection();
- + String getResponse = connection.get("event?schoolid=" + schoolId);
- + Gson g = new GsonBuilder().create();
- + Event[] events = g.fromJson(getResponse, Event[].class); //vllt. in eine ArrayList packen, besser in JSP
- +
- + this.session.setAttribute("events", events);
- + }
- +
- +}
- diff --git a/src/java/misc/URLConnection.java b/src/java/misc/URLConnection.java
- index a654156..c849bb1 100644
- --- a/src/java/misc/URLConnection.java
- +++ b/src/java/misc/URLConnection.java
- @@ -7,10 +7,6 @@ import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.URL;
- -
- -/**
- - * Created by Matze on 12.07.2017.
- - */
- public class URLConnection {
- private final String baseUrl;
- diff --git a/src/java/servlets/ChangerServlet.java b/src/java/servlets/ChangerServlet.java
- new file mode 100644
- index 0000000..6f1b581
- --- /dev/null
- +++ b/src/java/servlets/ChangerServlet.java
- @@ -0,0 +1,33 @@
- +package servlets;
- +
- +import java.io.IOException;
- +import javax.servlet.ServletException;
- +import javax.servlet.annotation.WebServlet;
- +import javax.servlet.http.HttpServlet;
- +import javax.servlet.http.HttpServletRequest;
- +import javax.servlet.http.HttpServletResponse;
- +import misc.BeanChanger;
- +
- +@WebServlet(name = "ChangerServlet", urlPatterns = {"/ChangerServlet"})
- +public class ChangerServlet extends HttpServlet {
- +
- +
- + protected void doTheStuff(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- +
- + BeanChanger beanChanger = new BeanChanger(request, response);
- + //wenn changes auf beans dann hier is the way to go
- + }
- +
- + @Override
- + protected void doPost(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- + doTheStuff(request, response);
- + }
- +
- + @Override
- + protected void doGet(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- + doPost(request, response);
- + }
- +}
- diff --git a/src/java/servlets/LoginServlet.java b/src/java/servlets/LoginServlet.java
- index 10d3a09..302584b 100644
- --- a/src/java/servlets/LoginServlet.java
- +++ b/src/java/servlets/LoginServlet.java
- @@ -1,8 +1,5 @@
- package servlets;
- -import beans.Teacher;
- -import com.google.gson.Gson;
- -import com.google.gson.GsonBuilder;
- import misc.URLConnection;
- import javax.servlet.ServletException;
- @@ -11,10 +8,8 @@ import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- -
- -/**
- - * Created by Matze on 11.07.2017.
- - */
- +import javax.servlet.RequestDispatcher;
- +import misc.BeanFiller;
- @WebServlet(urlPatterns = {"/LoginServlet"})
- public class LoginServlet extends HttpServlet {
- @@ -24,19 +19,39 @@ public class LoginServlet extends HttpServlet {
- String username = request.getParameter("username");
- String password = request.getParameter("password");
- String type = request.getParameter("type");
- -
- +
- + BeanFiller beanfiller = new BeanFiller(request,response);
- String json = "{username: " + username + ", password: " + password + ", type: " + type + "}";
- -
- - URLConnection connection = new URLConnection();
- - String postResponse = connection.post("login", json);
- -
- - if (postResponse.length() > 3){
- - response.getWriter().print("login successful");
- - Gson g = new GsonBuilder().create();
- - request.setAttribute(type, g.fromJson(postResponse,Teacher[].class)); //muss hier noch geändert werden damit allgemeingültig!
- +
- + if (checkLogin(json)){
- +
- + switch (type) {
- + case "teacher":
- + beanfiller.fillTeacherBeans(json);
- + break;
- + case "child":
- + beanfiller.fillChildBeans(json);
- + break;
- + case "parent":
- + beanfiller.fillParentBeans(json);
- + break;
- + case "schooladmin":
- + beanfiller.fillSchoolAdminBeans(json);
- + break;
- + case "ministerium":
- + beanfiller.fillMinisteriumBeans(json);
- + break;
- + default:
- + beanfiller.fail();
- + break;
- + }
- +
- + RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/home.jsp");
- + dispatcher.forward(request, response);
- }
- - else
- + else{
- response.getWriter().print("login fehlgeschlagen");
- + }
- }
- @Override
- @@ -48,4 +63,11 @@ public class LoginServlet extends HttpServlet {
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- doPost(request, response);
- }
- +
- + public boolean checkLogin(String json) throws IOException, ServletException{
- + URLConnection connection = new URLConnection();
- + String postResponse = connection.post("login", json);
- + return postResponse.length() > 3;
- + }
- +
- }
- diff --git a/src/java/servlets/SchoolClassSwitcher.java b/src/java/servlets/SchoolClassSwitcher.java
- new file mode 100644
- index 0000000..4ec8781
- --- /dev/null
- +++ b/src/java/servlets/SchoolClassSwitcher.java
- @@ -0,0 +1,35 @@
- +package servlets;
- +
- +import java.io.IOException;
- +import javax.servlet.RequestDispatcher;
- +import javax.servlet.ServletException;
- +import javax.servlet.annotation.WebServlet;
- +import javax.servlet.http.HttpServlet;
- +import javax.servlet.http.HttpServletRequest;
- +import javax.servlet.http.HttpServletResponse;
- +import misc.BeanFiller;
- +
- +@WebServlet(name = "SchoolClassSwitcher", urlPatterns = {"/SchoolClassSwitcher"})
- +public class SchoolClassSwitcher extends HttpServlet {
- +
- + protected void processRequest(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- + int schoolId = (Integer) Integer.parseInt(request.getParameter("schoolClassButton"));
- + BeanFiller beanfiller = new BeanFiller(request, response);
- + beanfiller.createSpecificPupilBeanForSchoolClass(schoolId);
- + RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/klassen.jsp");
- + dispatcher.forward(request, response);
- + }
- +
- + @Override
- + protected void doGet(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- + processRequest(request, response);
- + }
- +
- + @Override
- + protected void doPost(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- + processRequest(request, response);
- + }
- +}
- diff --git a/src/java/servlets/SiteSwitcher.java b/src/java/servlets/SiteSwitcher.java
- new file mode 100644
- index 0000000..ff28eaf
- --- /dev/null
- +++ b/src/java/servlets/SiteSwitcher.java
- @@ -0,0 +1,77 @@
- +package servlets;
- +
- +import java.io.IOException;
- +import java.sql.SQLException;
- +import javax.servlet.RequestDispatcher;
- +import javax.servlet.ServletException;
- +import javax.servlet.annotation.WebServlet;
- +import javax.servlet.http.HttpServlet;
- +import javax.servlet.http.HttpServletRequest;
- +import javax.servlet.http.HttpServletResponse;
- +
- +
- +@WebServlet(urlPatterns = {"/SiteSwitcher"})
- +public class SiteSwitcher extends HttpServlet {
- +
- + protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws SQLException, ServletException, IOException {
- + //checkForLoggedIn(request, response);
- + String action = request.getParameter("klick");
- + String site;
- + switch(action){
- + case "events":
- + site = "/jsp/events.jsp";
- + break;
- + case "home":
- + site = "/jsp/home.jsp";
- + break;
- + case "klassen":
- + site = "/jsp/klassen.jsp";
- + break;
- + case "nachrichten":
- + site = "/jsp/nachrichten.jsp";
- + break;
- + case "hausaufgaben":
- + site = "/jsp/hausaufgaben.jsp";
- + break;
- + case "logout":
- + request.getSession().invalidate();
- + site = "/index.jsp";
- + break;
- + default:
- + site = "/jsp/home.jsp";
- + break;
- + }
- +
- + RequestDispatcher dispatcher = request.getRequestDispatcher(site);
- + dispatcher.forward(request, response);
- + }
- +
- + @Override
- + protected void doGet(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- + try {
- + processRequest(request, response);
- + } catch (SQLException ex) {
- + // do something
- + }
- + }
- +
- + @Override
- + protected void doPost(HttpServletRequest request, HttpServletResponse response)
- + throws ServletException, IOException {
- + try {
- + processRequest(request, response);
- + } catch (SQLException ex) {
- + // do something
- + }
- + }
- +
- +// private void checkForLoggedIn(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- +// HttpSession session = request.getSession();
- +// UserBean ubean = (UserBean) session.getAttribute("user");
- +// if (ubean == null) {
- +// RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
- +// dispatcher.forward(request, response);
- +// }
- +// }
- +}
- \ No newline at end of file
- diff --git a/web/css/style.css b/web/css/style.css
- new file mode 100644
- index 0000000..0a04fdd
- --- /dev/null
- +++ b/web/css/style.css
- @@ -0,0 +1,98 @@
- +#menuBar{
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + text-align: center;
- + padding-top: 15px;
- +}
- +
- +.inhaltTop{
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + text-align: center;
- + padding-top: 15px;
- + padding-bottom: 15px;
- + margin-top: 10px;
- +}
- +
- +.homeBottomHausaufgaben{
- + width: 45%;
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + padding-top: 15px;
- + margin-top: 10px;
- + margin-left: 30px;
- + text-align: center;
- + margin-right: 20px;
- + float: left;
- +}
- +
- +.homeBottomEvents{
- + width: 45%;
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + padding-top: 15px;
- + margin-top: 10px;
- + text-align: center;
- + float: left;
- +}
- +
- +.klassenBottomSchueler{
- + width: 20%;
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + padding-top: 15px;
- + margin-top: 10px;
- + margin-right: 20px;
- + margin-left: 20px;
- + text-align: center;
- + float: left;
- +}
- +
- +.klassenBottomNachrichten{
- + width: 20%;
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + padding-top: 15px;
- + margin-top: 10px;
- + margin-right: 20px;
- + text-align: center;
- + float: left;
- +}
- +
- +.klassenBottomHausaufgaben{
- + width: 25%;
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + padding-top: 15px;
- + margin-top: 10px;
- + margin-right: 20px;
- + text-align: center;
- + float: left;
- +}
- +
- +.klassenBottomEvents{
- + width: 25%;
- + border-style: solid;
- + border-width: 1px;
- + border-color: black;
- + padding-top: 15px;
- + margin-top: 10px;
- + text-align: center;
- + float: left;
- +}
- +
- +.event{
- + border-style: solid;
- + border-width: 2px;
- + border-color: green;
- + text-align: center;
- + margin-bottom: 10px;
- + float: inside;
- +}
- \ No newline at end of file
- diff --git a/web/jsp/events.jsp b/web/jsp/events.jsp
- new file mode 100644
- index 0000000..907f2c1
- --- /dev/null
- +++ b/web/jsp/events.jsp
- @@ -0,0 +1,27 @@
- +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
- +<%@ page language="Java" contentType="text/html" pageEncoding="UTF-8" %>
- +<html lang="de">
- + <head>
- + <meta charset="utf-8">
- + <meta name="viewport" content="width=device-width, initial-scale=1.0">
- + <link rel="stylesheet" href="<%= request.getContextPath()%>/css/style.css">
- + <title>Events</title>
- + </head>
- +
- +
- + <body>
- +
- + <%@ include file="header.jspf" %>
- +
- + <div class="inhalt">
- +
- + Das ist die Events-Seite
- +
- + </div>
- +
- + <footer>
- +
- + </footer>
- +
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/web/jsp/hausaufgaben.jsp b/web/jsp/hausaufgaben.jsp
- new file mode 100644
- index 0000000..f6c3120
- --- /dev/null
- +++ b/web/jsp/hausaufgaben.jsp
- @@ -0,0 +1,27 @@
- +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
- +<%@ page language="Java" contentType="text/html" pageEncoding="UTF-8" %>
- +<html lang="de">
- + <head>
- + <meta charset="utf-8">
- + <meta name="viewport" content="width=device-width, initial-scale=1.0">
- + <link rel="stylesheet" href="<%= request.getContextPath()%>/css/style.css">
- + <title>Hausaufgaben</title>
- + </head>
- +
- +
- + <body>
- +
- + <%@ include file="header.jspf" %>
- +
- + <div class="inhalt">
- +
- + Das ist die Hausaufgaben-Seite
- +
- + </div>
- +
- + <footer>
- +
- + </footer>
- +
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/web/jsp/header.jspf b/web/jsp/header.jspf
- new file mode 100644
- index 0000000..6f63608
- --- /dev/null
- +++ b/web/jsp/header.jspf
- @@ -0,0 +1,17 @@
- +<%
- + if (session.getAttribute("user") == null) {
- + request.getRequestDispatcher("/index.jsp").forward(request, response);
- + }
- +%>
- +<header>
- + <div id="menuBar">
- + <form action="SiteSwitcher" method="post">
- + <button type="submit" name="klick" value="events" id="eventseite" class="menuebutton">Events</button>
- + <button type="submit" name="klick" value="hausaufgaben" id="hausaufgabenseite" class="menuebutton">Hausaufgaben</button>
- + <button type="submit" name="klick" value="home" id="homeseite" class="menuebutton">Home</button>
- + <button type="submit" name="klick" value="klassen" id="klassenseite" class="menuebutton">Klassen</button>
- + <button type="submit" name="klick" value="nachrichten" id="nachrichtenseite" class="menuebutton">Nachrichten</button>
- + <button type="submit" name="klick" value="logout" id="logoutseite" class="menuebutton">Logout</button>
- + </form>
- + </div>
- +</header>
- \ No newline at end of file
- diff --git a/web/jsp/home.jsp b/web/jsp/home.jsp
- new file mode 100644
- index 0000000..79505d9
- --- /dev/null
- +++ b/web/jsp/home.jsp
- @@ -0,0 +1,65 @@
- +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
- +<%@ page language="Java" contentType="text/html" pageEncoding="UTF-8" %>
- +<html lang="de">
- + <head>
- + <meta charset="utf-8">
- + <meta name="viewport" content="width=device-width, initial-scale=1.0">
- + <link rel="stylesheet" href="<%= request.getContextPath()%>/css/style.css">
- + <title>Home</title>
- + </head>
- +
- +
- + <body>
- +
- + <%@ include file="header.jspf" %>
- +
- + <div class="inhaltTop">
- + Das ist die Home-Seite
- + <br>
- + <br>
- + Willkommen (${user.object.firstname} ${user.object.lastname}) der Schule (${user.object.school.name})
- + </div>
- +
- + <div class="homeBottomHausaufgaben">
- + Alle von Ihnen aufgegebene Hausaufgaben:
- + <br>
- + <br>
- + Abgabedatum:
- + <input type="date" id="abgabe" name="abgabe" required pattern="[0-9]{2}.[0-9]{2}.[0-9]{4}">
- + <br>
- + Erstellungsdatum:
- + <input type="date" id="erstellung" name="erstellung" required pattern="[0-9]{2}.[0-9]{2}.[0-9]{4}">
- + <br>
- + <br>
- + <c:forEach items="${homework}" var="homework">
- + <div class="event">
- + ${homework.schoolclass.name}
- + <br>
- + ${homework.homework}
- + </div>
- + <br>
- + </c:forEach>
- + </div>
- +
- + <div class="homeBottomEvents">
- + Alle anstehenden Events:
- + <br>
- + <br>
- + <c:forEach items="${events}" var="event">
- + <div class="event">
- + ${event.title}
- + <br>
- + ${event.description}
- + <br>
- + ${event.schooldate}
- + </div>
- + <br>
- + </c:forEach>
- + </div>
- +
- + <footer>
- +
- + </footer>
- +
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/web/jsp/klassen.jsp b/web/jsp/klassen.jsp
- new file mode 100644
- index 0000000..38a0817
- --- /dev/null
- +++ b/web/jsp/klassen.jsp
- @@ -0,0 +1,70 @@
- +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
- +<%@ page language="Java" contentType="text/html" pageEncoding="UTF-8" %>
- +<html lang="de">
- + <head>
- + <meta charset="utf-8">
- + <meta name="viewport" content="width=device-width, initial-scale=1.0">
- + <link rel="stylesheet" href="<%= request.getContextPath()%>/css/style.css">
- + <title>Klassen</title>
- + </head>
- +
- + <body>
- +
- + <%@ include file="header.jspf" %>
- +
- + <div class="inhaltTop">
- + Das ist die Klassen-Seite
- + <button type="submit" name="klick" value="events" id="eventseite" class="menuebutton">Klasse hinzufügen</button>
- + <br>
- + <br>
- + <form name="schoolClassAuswahl" action="SchoolClassSwitcher" method="post">
- + <c:forEach items="${schoolclass}" var="class">
- + <button name="schoolClassButton" value="${class.id}">${class.name}</button>
- + </c:forEach>
- + </form>
- + </div>
- +
- + <c:if test="${!empty pupils}">
- + <div class="klassenBottomSchueler">
- + Schüler der Klasse (${pupils[0].schoolclass.name}):
- + <br>
- + <br>
- + <c:forEach items="${pupils}" var="pupil">
- + <label>
- + <input type="checkbox" name="pupil" value="${pupil.id}">
- + ${pupil.firstname} , ${pupil.lastname}
- + </label>
- + <br>
- + </c:forEach>
- + </div>
- +
- + <div class="klassenBottomNachrichten">
- + Nachrichten oder Fehlzeiten:
- + <br>
- + <br>
- + <button type="submit" name="klick" value="events" id="eventseite" class="menuebutton">Nachricht an die Eltern</button>
- + <br>
- + <button type="submit" name="klick" value="hausaufgaben" id="hausaufgabenseite" class="menuebutton">Fehlzeiten eintragen</button>
- + </div>
- +
- + <div class="klassenBottomHausaufgaben">
- + Hausaufgaben:
- + <br>
- + <br>
- + <button type="submit" name="klick" value="events" id="eventseite" class="menuebutton">Hausaufgabe hinzufügen</button>
- + </div>
- +
- + <div class="klassenBottomEvents">
- + Events:
- + <br>
- + <br>
- + <button type="submit" name="klick" value="events" id="eventseite" class="menuebutton">Event hinzufügen</button>
- + </div>
- + </c:if>
- +
- + <footer>
- +
- + </footer>
- +
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/web/jsp/nachrichten.jsp b/web/jsp/nachrichten.jsp
- new file mode 100644
- index 0000000..c97a71c
- --- /dev/null
- +++ b/web/jsp/nachrichten.jsp
- @@ -0,0 +1,27 @@
- +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
- +<%@ page language="Java" contentType="text/html" pageEncoding="UTF-8" %>
- +<html lang="de">
- + <head>
- + <meta charset="utf-8">
- + <meta name="viewport" content="width=device-width, initial-scale=1.0">
- + <link rel="stylesheet" href="<%= request.getContextPath()%>/css/style.css">
- + <title>Nachrichten</title>
- + </head>
- +
- +
- + <body>
- +
- + <%@ include file="header.jspf" %>
- +
- + <div class="inhalt">
- +
- + Das ist die Nachrichten-Seite
- +
- + </div>
- +
- + <footer>
- +
- + </footer>
- +
- + </body>
- +</html>
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement