Your Pics
- <% - java.util.LinkedListNo Pictures found
- <% - } else { - Iterator<% - - } - } - %> -
POST method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
-
- String username=request.getParameter("username");
- String password=request.getParameter("password");
-
- User us=new User();
- us.setCluster(cluster);
- boolean isValid=us.IsValidUser(username, password);
- HttpSession session=request.getSession();
- System.out.println("Session in servlet "+session);
- if (isValid){
- LoggedIn lg= new LoggedIn();
- lg.setLogedin();
- lg.setUsername(username);
- //request.setAttribute("LoggedIn", lg);
-
- session.setAttribute("LoggedIn", lg);
- System.out.println("Session in servlet "+session);
- RequestDispatcher rd=request.getRequestDispatcher("index.jsp");
- rd.forward(request,response);
-
- }else{
- response.sendRedirect("/Instagrim/login.jsp");
- }
-
- }
-
- /**
- * Returns a short description of the servlet.
- *
- * @return a String containing servlet description
- */
- @Override
- public String getServletInfo() {
- return "Short description";
- }//
-
-}
diff --git a/src/main/java/uk/ac/dundee/computing/aec/instagrim/servlets/Register.java b/src/main/java/uk/ac/dundee/computing/aec/instagrim/servlets/Register.java
deleted file mode 100644
index 20ae736a..00000000
--- a/src/main/java/uk/ac/dundee/computing/aec/instagrim/servlets/Register.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package uk.ac.dundee.computing.aec.instagrim.servlets;
-
-import com.datastax.driver.core.Cluster;
-import java.io.IOException;
-import java.io.PrintWriter;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletConfig;
-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 uk.ac.dundee.computing.aec.instagrim.lib.CassandraHosts;
-import uk.ac.dundee.computing.aec.instagrim.models.User;
-
-/**
- *
- * @author Administrator
- */
-@WebServlet(name = "Register", urlPatterns = {"/Register"})
-public class Register extends HttpServlet {
- Cluster cluster=null;
- public void init(ServletConfig config) throws ServletException {
- // TODO Auto-generated method stub
- cluster = CassandraHosts.getCluster();
- }
-
-
-
-
- /**
- * Handles the HTTP POST method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- String username=request.getParameter("username");
- String password=request.getParameter("password");
-
- User us=new User();
- us.setCluster(cluster);
- us.RegisterUser(username, password);
-
- response.sendRedirect("/Instagrim");
-
- }
-
- /**
- * Returns a short description of the servlet.
- *
- * @return a String containing servlet description
- */
- @Override
- public String getServletInfo() {
- return "Short description";
- }//
-
-}
diff --git a/src/main/java/uk/ac/dundee/computing/aec/instagrim/stores/LoggedIn.java b/src/main/java/uk/ac/dundee/computing/aec/instagrim/stores/LoggedIn.java
deleted file mode 100644
index 8e1574e2..00000000
--- a/src/main/java/uk/ac/dundee/computing/aec/instagrim/stores/LoggedIn.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package uk.ac.dundee.computing.aec.instagrim.stores;
-
-/**
- *
- * @author Administrator
- */
-public class LoggedIn {
- boolean logedin=false;
- String Username=null;
- public void LogedIn(){
-
- }
-
- public void setUsername(String name){
- this.Username=name;
- }
- public String getUsername(){
- return Username;
- }
- public void setLogedin(){
- logedin=true;
- }
- public void setLogedout(){
- logedin=false;
- }
-
- public void setLoginState(boolean logedin){
- this.logedin=logedin;
- }
- public boolean getlogedin(){
- return logedin;
- }
-}
diff --git a/src/main/java/uk/ac/dundee/computing/aec/instagrim/stores/Pic.java b/src/main/java/uk/ac/dundee/computing/aec/instagrim/stores/Pic.java
deleted file mode 100644
index c36e3f6c..00000000
--- a/src/main/java/uk/ac/dundee/computing/aec/instagrim/stores/Pic.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package uk.ac.dundee.computing.aec.instagrim.stores;
-
-import com.datastax.driver.core.utils.Bytes;
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class Pic {
-
- private ByteBuffer bImage = null;
- private int length;
- private String type;
- private java.util.UUID UUID=null;
-
- public void Pic() {
-
- }
- public void setUUID(java.util.UUID UUID){
- this.UUID =UUID;
- }
- public String getSUUID(){
- return UUID.toString();
- }
- public void setPic(ByteBuffer bImage, int length,String type) {
- this.bImage = bImage;
- this.length = length;
- this.type=type;
- }
-
- public ByteBuffer getBuffer() {
- return bImage;
- }
-
- public int getLength() {
- return length;
- }
-
- public String getType(){
- return type;
- }
-
- public byte[] getBytes() {
-
- byte image[] = Bytes.getArray(bImage);
- return image;
- }
-
-}
diff --git a/src/main/java/uk/ac/dundee/computing/aec/instagrin/filters/ProtectPages.java b/src/main/java/uk/ac/dundee/computing/aec/instagrin/filters/ProtectPages.java
deleted file mode 100644
index 7e284d6c..00000000
--- a/src/main/java/uk/ac/dundee/computing/aec/instagrin/filters/ProtectPages.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package uk.ac.dundee.computing.aec.instagrin.filters;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import javax.servlet.DispatcherType;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.annotation.WebFilter;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import uk.ac.dundee.computing.aec.instagrim.stores.LoggedIn;
-
-/**
- *
- * @author Administrator
- */
-@WebFilter(filterName = "ProtectPages", urlPatterns = {"/upload.jsp"}, dispatcherTypes = {DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE})
-public class ProtectPages implements Filter {
-
- private static final boolean debug = true;
-
- // The filter configuration object we are associated with. If
- // this value is null, this filter instance is not currently
- // configured.
- private FilterConfig filterConfig = null;
-
- public ProtectPages() {
- }
-
- private void doBeforeProcessing(ServletRequest request, ServletResponse response)
- throws IOException, ServletException {
- if (debug) {
- log("ProtectPages:DoBeforeProcessing");
- }
-
- // Write code here to process the request and/or response before
- // the rest of the filter chain is invoked.
- // For example, a logging filter might log items on the request object,
- // such as the parameters.
- /*
- for (Enumeration en = request.getParameterNames(); en.hasMoreElements(); ) {
- String name = (String)en.nextElement();
- String values[] = request.getParameterValues(name);
- int n = values.length;
- StringBuffer buf = new StringBuffer();
- buf.append(name);
- buf.append("=");
- for(int i=0; i < n; i++) {
- buf.append(values[i]);
- if (i < n-1)
- buf.append(",");
- }
- log(buf.toString());
- }
- */
- }
-
- private void doAfterProcessing(ServletRequest request, ServletResponse response)
- throws IOException, ServletException {
- if (debug) {
- log("ProtectPages:DoAfterProcessing");
- }
-
- // Write code here to process the request and/or response after
- // the rest of the filter chain is invoked.
- // For example, a logging filter might log the attributes on the
- // request object after the request has been processed.
- /*
- for (Enumeration en = request.getAttributeNames(); en.hasMoreElements(); ) {
- String name = (String)en.nextElement();
- Object value = request.getAttribute(name);
- log("attribute: " + name + "=" + value.toString());
-
- }
- */
- // For example, a filter might append something to the response.
- /*
- PrintWriter respOut = new PrintWriter(response.getWriter());
- respOut.println("This has been appended by an intrusive filter."); - */ - } - - /** - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param chain The filter chain we are processing - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet error occurs - */ - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) - throws IOException, ServletException { - - if (debug) { - log("ProtectPages:doFilter()"); - } - - doBeforeProcessing(request, response); - System.out.println("Doing filter"); - HttpServletRequest httpReq = (HttpServletRequest) request; - HttpSession session=httpReq.getSession(false); - LoggedIn li=(LoggedIn)session.getAttribute("LoggedIn"); - System.out.println("Session in filter "+session); - if ((li == null) || (li.getlogedin()==false)){ - System.out.println("Foward to login"); - RequestDispatcher rd=request.getRequestDispatcher("/login.jsp"); - rd.forward(request,response); - - - } - Throwable problem = null; - try { - chain.doFilter(request, response); - } catch (Throwable t) { - // If an exception is thrown somewhere down the filter chain, - // we still want to execute our after processing, and then - // rethrow the problem after that. - problem = t; - t.printStackTrace(); - } - - doAfterProcessing(request, response); - - // If there was a problem, we want to rethrow it if it is - // a known type, otherwise log it. - if (problem != null) { - if (problem instanceof ServletException) { - throw (ServletException) problem; - } - if (problem instanceof IOException) { - throw (IOException) problem; - } - sendProcessingError(problem, response); - } - } - - /** - * Return the filter configuration object for this filter. - */ - public FilterConfig getFilterConfig() { - return (this.filterConfig); - } - - /** - * Set the filter configuration object for this filter. - * - * @param filterConfig The filter configuration object - */ - public void setFilterConfig(FilterConfig filterConfig) { - this.filterConfig = filterConfig; - } - - /** - * Destroy method for this filter - */ - public void destroy() { - } - - /** - * Init method for this filter - */ - public void init(FilterConfig filterConfig) { - this.filterConfig = filterConfig; - if (filterConfig != null) { - if (debug) { - log("ProtectPages:Initializing filter"); - } - } - } - - /** - * Return a String representation of this object. - */ - @Override - public String toString() { - if (filterConfig == null) { - return ("ProtectPages()"); - } - StringBuffer sb = new StringBuffer("ProtectPages("); - sb.append(filterConfig); - sb.append(")"); - return (sb.toString()); - } - - private void sendProcessingError(Throwable t, ServletResponse response) { - String stackTrace = getStackTrace(t); - - if (stackTrace != null && !stackTrace.equals("")) { - try { - response.setContentType("text/html"); - PrintStream ps = new PrintStream(response.getOutputStream()); - PrintWriter pw = new PrintWriter(ps); - pw.print("\n
\n\n");
- pw.print(stackTrace);
- pw.print("\n"); //NOI18N
- pw.close();
- ps.close();
- response.getOutputStream().close();
- } catch (Exception ex) {
- }
- } else {
- try {
- PrintStream ps = new PrintStream(response.getOutputStream());
- t.printStackTrace(ps);
- ps.close();
- response.getOutputStream().close();
- } catch (Exception ex) {
- }
- }
- }
-
- public static String getStackTrace(Throwable t) {
- String stackTrace = null;
- try {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- t.printStackTrace(pw);
- pw.close();
- sw.close();
- stackTrace = sw.getBuffer().toString();
- } catch (Exception ex) {
- }
- return stackTrace;
- }
-
- public void log(String msg) {
- filterConfig.getServletContext().log(msg);
- }
-
-}
diff --git a/src/main/webapp/META-INF/context.xml b/src/main/webapp/META-INF/context.xml
index 5bc0dbd9..5bee3dc3 100644
--- a/src/main/webapp/META-INF/context.xml
+++ b/src/main/webapp/META-INF/context.xml
@@ -1,2 +1,2 @@
-No Pictures found
- <% - } else { - Iterator