Thread: [Cruce-commit] SF.net SVN: cruce:[138] JSP/trunk/Forum
Status: Beta
Brought to you by:
caiusb
|
From: <ca...@us...> - 2010-05-11 09:30:30
|
Revision: 138
http://cruce.svn.sourceforge.net/cruce/?rev=138&view=rev
Author: caiusb
Date: 2010-05-11 09:30:23 +0000 (Tue, 11 May 2010)
Log Message:
-----------
The files.
Added Paths:
-----------
JSP/trunk/Forum/.classpath
JSP/trunk/Forum/.project
JSP/trunk/Forum/.settings/
JSP/trunk/Forum/.settings/.jsdtscope
JSP/trunk/Forum/.settings/org.eclipse.jdt.core.prefs
JSP/trunk/Forum/.settings/org.eclipse.wst.common.component
JSP/trunk/Forum/.settings/org.eclipse.wst.common.project.facet.core.xml
JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.container
JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.name
JSP/trunk/Forum/WebContent/
JSP/trunk/Forum/WebContent/Hello.jsp
JSP/trunk/Forum/WebContent/META-INF/
JSP/trunk/Forum/WebContent/META-INF/MANIFEST.MF
JSP/trunk/Forum/WebContent/WEB-INF/
JSP/trunk/Forum/WebContent/WEB-INF/lib/
JSP/trunk/Forum/WebContent/WEB-INF/web.xml
JSP/trunk/Forum/src/
JSP/trunk/Forum/src/prc/
JSP/trunk/Forum/src/prc/bubulina/
JSP/trunk/Forum/src/prc/bubulina/forum/
JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java
JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java
Added: JSP/trunk/Forum/.classpath
===================================================================
--- JSP/trunk/Forum/.classpath (rev 0)
+++ JSP/trunk/Forum/.classpath 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-sun-1.6.0.20">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="lib" path="/usr/share/tomcat6/lib/servlet-api.jar"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Added: JSP/trunk/Forum/.project
===================================================================
--- JSP/trunk/Forum/.project (rev 0)
+++ JSP/trunk/Forum/.project 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Forum</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
Added: JSP/trunk/Forum/.settings/.jsdtscope
===================================================================
--- JSP/trunk/Forum/.settings/.jsdtscope (rev 0)
+++ JSP/trunk/Forum/.settings/.jsdtscope 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added: JSP/trunk/Forum/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- JSP/trunk/Forum/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ JSP/trunk/Forum/.settings/org.eclipse.jdt.core.prefs 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,7 @@
+#Tue May 11 10:28:54 EEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: JSP/trunk/Forum/.settings/org.eclipse.wst.common.component
===================================================================
--- JSP/trunk/Forum/.settings/org.eclipse.wst.common.component (rev 0)
+++ JSP/trunk/Forum/.settings/org.eclipse.wst.common.component 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="Forum">
+ <wb-resource deploy-path="/" source-path="/WebContent"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+ <property name="context-root" value="Forum"/>
+ <property name="java-output-path" value="/Forum/build/classes"/>
+ </wb-module>
+</project-modules>
Added: JSP/trunk/Forum/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
--- JSP/trunk/Forum/.settings/org.eclipse.wst.common.project.facet.core.xml (rev 0)
+++ JSP/trunk/Forum/.settings/org.eclipse.wst.common.project.facet.core.xml 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="jst.web"/>
+ <fixed facet="jst.java"/>
+ <installed facet="jst.java" version="6.0"/>
+ <installed facet="jst.web" version="2.4"/>
+</faceted-project>
Added: JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
--- JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.container (rev 0)
+++ JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.container 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added: JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
--- JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.name (rev 0)
+++ JSP/trunk/Forum/.settings/org.eclipse.wst.jsdt.ui.superType.name 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added: JSP/trunk/Forum/WebContent/Hello.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Hello.jsp (rev 0)
+++ JSP/trunk/Forum/WebContent/Hello.jsp 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,12 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Hello, World!</title>
+</head>
+<body>
+<form action="HelloServlet" method="GET"></form>
+</body>
+</html>
\ No newline at end of file
Added: JSP/trunk/Forum/WebContent/META-INF/MANIFEST.MF
===================================================================
--- JSP/trunk/Forum/WebContent/META-INF/MANIFEST.MF (rev 0)
+++ JSP/trunk/Forum/WebContent/META-INF/MANIFEST.MF 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added: JSP/trunk/Forum/WebContent/WEB-INF/web.xml
===================================================================
--- JSP/trunk/Forum/WebContent/WEB-INF/web.xml (rev 0)
+++ JSP/trunk/Forum/WebContent/WEB-INF/web.xml 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>Forum</display-name>
+ <servlet>
+ <description>
+ </description>
+ <display-name>HelloServlet</display-name>
+ <servlet-name>HelloServlet</servlet-name>
+ <servlet-class>
+ prc.bubulina.forum.HelloServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>HelloServlet</servlet-name>
+ <url-pattern>/HelloServlet</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
+ </welcome-file-list>
+</web-app>
Added: JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,7 @@
+package prc.bubulina.forum;
+
+public class Hello {
+ public String getHello() {
+ return "Hello, World!";
+ }
+}
Added: JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java 2010-05-11 09:30:23 UTC (rev 138)
@@ -0,0 +1,40 @@
+package prc.bubulina.forum;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Servlet implementation class HelloServlet
+ */
+public class HelloServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ private Hello hello;
+
+ /**
+ * Default constructor.
+ */
+ public HelloServlet() {
+ hello = new Hello();
+ }
+
+ /**
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ PrintWriter out = response.getWriter();
+ out.println("Hello, World!");
+ }
+
+ /**
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // TODO Auto-generated method stub
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <hor...@us...> - 2010-05-14 11:51:08
|
Revision: 140
http://cruce.svn.sourceforge.net/cruce/?rev=140&view=rev
Author: horiaradu
Date: 2010-05-14 11:51:01 +0000 (Fri, 14 May 2010)
Log Message:
-----------
Am adaugat clasele de date. Am facut pt user o clasa de management care scrie in bd, citeste, etc...
Am pus scriptu de configurare, dar are niste linii in plus care vor disparea dupa ce termin si vad ca merge.
Clasa Test nu e un test, ci e un main cu care ma joc eu si cu care va puteti juca si voi daca vreti.
In BD am pus userul horia si parola barcelona. Am facut sa mearga pe localhost. E ok pt ca serverul si BD vor fi pe acelasi PC.
Modified Paths:
--------------
JSP/trunk/Forum/.classpath
Added Paths:
-----------
JSP/trunk/Forum/bd_script.sql
JSP/trunk/Forum/build/
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java
JSP/trunk/Forum/src/prc/bubulina/forum/test/
JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
Modified: JSP/trunk/Forum/.classpath
===================================================================
--- JSP/trunk/Forum/.classpath 2010-05-11 20:29:42 UTC (rev 139)
+++ JSP/trunk/Forum/.classpath 2010-05-14 11:51:01 UTC (rev 140)
@@ -1,13 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-sun-1.6.0.20">
- <attributes>
- <attribute name="owner.project.facets" value="jst.java"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
- <classpathentry kind="lib" path="/usr/share/tomcat6/lib/servlet-api.jar"/>
- <classpathentry kind="output" path="build/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Added: JSP/trunk/Forum/bd_script.sql
===================================================================
--- JSP/trunk/Forum/bd_script.sql (rev 0)
+++ JSP/trunk/Forum/bd_script.sql 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,75 @@
+use forum;
+
+CREATE TABLE users (
+ user_id INT NOT NULL AUTO_INCREMENT,
+ name VARCHAR(30) NOT NULL,
+ password VARCHAR(50) NOT NULL,
+ email VARCHAR(30) NOT NULL,
+ post_count INT NOT NULL DEFAULT 0,
+ joined_date DATE NOT NULL,
+ PRIMARY KEY (user_id)
+);
+
+CREATE TABLE threads (
+ thread_id INT NOT NULL AUTO_INCREMENT,
+ name VARCHAR(30) NOT NULL,
+ topic_count INT NOT NULL DEFAULT 0,
+ PRIMARY KEY (thread_id)
+);
+
+CREATE TABLE topics (
+ topic_id INT NOT NULL AUTO_INCREMENT,
+ subject VARCHAR(30) NOT NULL,
+ thread_id INT NOT NULL,
+ PRIMARY KEY (topic_id),
+ FOREIGN KEY (thread_id) REFERENCES threads(thread_id) ON DELETE CASCADE
+);
+
+CREATE TABLE posts (
+ post_id INT NOT NULL AUTO_INCREMENT,
+ text MEDIUMBLOB NOT NULL,
+ subject VARCHAR(50) NOT NULL,
+ topic_id INT NOT NULL,
+ user_id INT NOT NULL,
+ PRIMARY KEY (post_id),
+ FOREIGN KEY (topic_id) REFERENCES topics(topic_id) ON DELETE CASCADE,
+ FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
+);
+
+GRANT all ON users TO horia;
+GRANT all ON threads TO horia;
+GRANT all ON topics TO horia;
+GRANT all ON posts TO horia;
+
+show columns from users;
+show columns from threads;
+show columns from topics;
+show columns from posts;
+
+INSERT INTO users (name, password, email, post_count, joined_date) VALUES
+ ("Horia", MD5("bubulina"), "hor...@gm...", 0, CURDATE()),
+ ("Caius", MD5("jijel"), "hor...@gm...", 0, CURDATE()),
+ ("Alin", MD5("yupidupi"), "hor...@gm...", 0, CURDATE());
+
+INSERT INTO users (name, password, email, post_count, joined_date) VALUES
+ ("Gigi", MD5("bubulina"), "hor...@gm...", 0, CURDATE());
+
+INSERT INTO threads (name, topic_count) VALUES
+ ("thread1", 0);
+
+INSERT INTO topics (subject, thread_id) VALUES
+ ("topic1", 2);
+INSERT INTO topics (subject, thread_id) VALUES
+ ("topic2", 2);
+UPDATE threads SET topic_count=2 WHERE thread_id=2;
+
+INSERT INTO posts (subject, text, topic_id, user_id) VALUES
+ ("Subject1", "Ana are multe mere. Eu merg la piata.", 8, 1);
+UPDATE users SET post_count=post_count+1 WHERE user_id=1;
+
+
+
+
+
+
+
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,36 @@
+package prc.bubulina.forum.data_access;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class ForumDAOFactory {
+ public static final String DRIVER = "com.mysql.jdbc.Driver";
+ public static final String DBURL = "jdbc:mysql://localhost:3306/forum";
+
+ public static Connection createConnection() {
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ return DriverManager.getConnection(DBURL, "horia", "barcelona");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static UserDAO getUserDAO() {
+ return new UserDAO();
+ }
+
+ public static ThreadDAO getThreadDAO() {
+ return new ThreadDAO();
+ }
+
+ public static TopicDAO getTopicDAO() {
+ return new TopicDAO();
+ }
+
+ public static PostDAO getPostDAO() {
+ return new PostDAO();
+ }
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,5 @@
+package prc.bubulina.forum.data_access;
+
+public class PostDAO {
+
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,5 @@
+package prc.bubulina.forum.data_access;
+
+public class ThreadDAO {
+
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,5 @@
+package prc.bubulina.forum.data_access;
+
+public class TopicDAO {
+
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,99 @@
+package prc.bubulina.forum.data_access;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import prc.bubulina.forum.dataclasses.User;
+
+public class UserDAO {
+ public User get(String userName) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE name=\"" + userName + "\"");
+ rs.first();
+
+ User result = new User(rs.getInt("user_id"), rs.getString("name"), rs.getString("password"), rs.getString("email"),
+ rs.getInt("post_count"), rs.getDate("joined_date"));
+
+ con.close();
+
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public boolean add(String name, String password, String email) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ String queryString = "INSERT INTO users (name, password, email, post_count, joined_date) " +
+ "VALUES (\"" + name + "\", \"" + password + "\", \"" +
+ email + "\", 0, CURDATE());";
+ System.out.println(queryString);
+ stmt.executeUpdate(queryString);
+
+ con.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public boolean update(User user, String name, String password, String email) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ String queryString = "UPDATE users SET name=\"" + name + "\", password=\"" + password + "\", " +
+ "email=\"" + email + "\" WHERE user_id=" + user.user_id + ";";
+ System.out.println(queryString);
+ stmt.executeUpdate(queryString);
+
+ con.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public boolean checkPassword(String name, String password) {
+ boolean result = false;
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ ResultSet rs = stmt.executeQuery("SELECT password FROM users WHERE name=\"" + name + "\"");
+ rs.first();
+
+ if (password.equals(rs.getString("password")))
+ result = true;
+
+ con.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ public boolean delete(String name) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ stmt.executeUpdate("DELETE FROM users WHERE name=\"" + name + "\"");
+
+ con.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,17 @@
+package prc.bubulina.forum.dataclasses;
+
+public class Post {
+ public int post_id;
+ public String subject;
+ public String text;
+ public int topic_id;
+ public int user_id;
+
+ public Post(int post_id, String subject, String text, int topic_id, int user_id) {
+ this.post_id = post_id;
+ this.subject = subject;
+ this.text = text;
+ this.topic_id = topic_id;
+ this.user_id = user_id;
+ }
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,13 @@
+package prc.bubulina.forum.dataclasses;
+
+public class Thread {
+ public int thread_id;
+ public String name;
+ public int topic_count;
+
+ public Thread(int thread_id, String name, int topic_count) {
+ this.thread_id = thread_id;
+ this.name = name;
+ this.topic_count = topic_count;
+ }
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,13 @@
+package prc.bubulina.forum.dataclasses;
+
+public class Topic {
+ public int topic_id;
+ public String subject;
+ public int thread_id;
+
+ public Topic(int topic_id, String subject, int thread_id) {
+ this.topic_id = topic_id;
+ this.subject = subject;
+ this.thread_id = thread_id;
+ }
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,21 @@
+package prc.bubulina.forum.dataclasses;
+
+import java.sql.Date;
+
+public class User {
+ public int user_id;
+ public String name;
+ public String password;
+ public String email;
+ public int post_count;
+ public Date joined_date;
+
+ public User(int user_id, String name, String password, String email, int post_count, Date joined_date) {
+ this.user_id = user_id;
+ this.name = name;
+ this.password = password;
+ this.email = email;
+ this.post_count = post_count;
+ this.joined_date = joined_date;
+ }
+}
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java 2010-05-14 11:51:01 UTC (rev 140)
@@ -0,0 +1,22 @@
+package prc.bubulina.forum.test;
+
+import prc.bubulina.forum.data_access.ForumDAOFactory;
+import prc.bubulina.forum.data_access.UserDAO;
+import prc.bubulina.forum.dataclasses.User;
+
+public class Test {
+ public static void main(String[] args) {
+ UserDAO userDao= ForumDAOFactory.getUserDAO();
+
+ //userDao.add("Horia", "bubulina", "hor...@gm...");
+
+ User user = userDao.get("Horia");
+ System.out.println(user.post_count + " " + user.password + " " + user.email);
+
+ System.out.println(userDao.checkPassword("Horia", "bubulina"));
+
+ userDao.update(user, "Horia", "hdsuahda", "h0...@ya...");
+
+ //userDao.delete("Horia");
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <hor...@us...> - 2010-05-14 17:02:14
|
Revision: 142
http://cruce.svn.sourceforge.net/cruce/?rev=142&view=rev
Author: horiaradu
Date: 2010-05-14 17:02:08 +0000 (Fri, 14 May 2010)
Log Message:
-----------
gata partea de data access. in functie de nevoi, mai adaugam sau modificam chestii.
pt simplitate, am pus momentan fara criptare, dar dupaia o sa adaug
Modified Paths:
--------------
JSP/trunk/Forum/bd_script.sql
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java
JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
Added Paths:
-----------
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/ForumThread.java
Removed Paths:
-------------
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java
Modified: JSP/trunk/Forum/bd_script.sql
===================================================================
--- JSP/trunk/Forum/bd_script.sql 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/bd_script.sql 2010-05-14 17:02:08 UTC (rev 142)
@@ -7,7 +7,9 @@
email VARCHAR(30) NOT NULL,
post_count INT NOT NULL DEFAULT 0,
joined_date DATE NOT NULL,
- PRIMARY KEY (user_id)
+ PRIMARY KEY (user_id),
+ UNIQUE(name),
+ UNIQUE(email)
);
CREATE TABLE threads (
@@ -36,40 +38,18 @@
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
);
-GRANT all ON users TO horia;
-GRANT all ON threads TO horia;
-GRANT all ON topics TO horia;
-GRANT all ON posts TO horia;
+GRANT all ON users TO horia@localhost;
+GRANT all ON threads TO horia@localhost;
+GRANT all ON topics TO horia@localhost;
+GRANT all ON posts TO horia@localhost;
show columns from users;
show columns from threads;
show columns from topics;
show columns from posts;
-
-INSERT INTO users (name, password, email, post_count, joined_date) VALUES
- ("Horia", MD5("bubulina"), "hor...@gm...", 0, CURDATE()),
- ("Caius", MD5("jijel"), "hor...@gm...", 0, CURDATE()),
- ("Alin", MD5("yupidupi"), "hor...@gm...", 0, CURDATE());
-INSERT INTO users (name, password, email, post_count, joined_date) VALUES
- ("Gigi", MD5("bubulina"), "hor...@gm...", 0, CURDATE());
-INSERT INTO threads (name, topic_count) VALUES
- ("thread1", 0);
-INSERT INTO topics (subject, thread_id) VALUES
- ("topic1", 2);
-INSERT INTO topics (subject, thread_id) VALUES
- ("topic2", 2);
-UPDATE threads SET topic_count=2 WHERE thread_id=2;
-
-INSERT INTO posts (subject, text, topic_id, user_id) VALUES
- ("Subject1", "Ana are multe mere. Eu merg la piata.", 8, 1);
-UPDATE users SET post_count=post_count+1 WHERE user_id=1;
-
-
-
-
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -22,8 +22,8 @@
return new UserDAO();
}
- public static ThreadDAO getThreadDAO() {
- return new ThreadDAO();
+ public static ForumThreadDAO getThreadDAO() {
+ return new ForumThreadDAO();
}
public static TopicDAO getTopicDAO() {
Copied: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java (from rev 140, JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java)
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -0,0 +1,85 @@
+package prc.bubulina.forum.data_access;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+
+import prc.bubulina.forum.dataclasses.ForumThread;
+import prc.bubulina.forum.dataclasses.Topic;
+
+public class ForumThreadDAO {
+ public ForumThread get(String threadName) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM threads WHERE name=\"" + threadName + "\"");
+ rs.first();
+
+ ForumThread result = new ForumThread(rs.getInt("thread_id"), rs.getString("name"), rs.getInt("topic_count"));
+
+ con.close();
+
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public ForumThread add(String name) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ String queryString = "INSERT INTO threads (name) " +
+ "VALUES (\"" + name + "\");";
+ System.out.println(queryString);
+ stmt.executeUpdate(queryString);
+
+ con.close();
+ return get(name);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public boolean delete(String name) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ stmt.executeUpdate("DELETE FROM threads WHERE name=\"" + name + "\"");
+
+ con.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public List<Topic> getTopics(String threadName) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT thread_id FROM threads WHERE name=\"" + threadName + "\"");
+ rs.next();
+ int thread_id = rs.getInt("thread_id");
+
+ rs = stmt.executeQuery("SELECT * from topics WHERE thread_id=" + thread_id);
+
+ List<Topic> result = new LinkedList<Topic>();
+ while (rs.next()) {
+ Topic t = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"));
+ result.add(t);
+ }
+ return result;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -1,5 +1,94 @@
package prc.bubulina.forum.data_access;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import prc.bubulina.forum.dataclasses.Post;
+
public class PostDAO {
+ public Post get(int post_id) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM posts WHERE post_id=" + post_id);
+ rs.first();
+
+ Post result = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
+ rs.getInt("topic_id"), rs.getInt("user_id"));
+
+ con.close();
+
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ public Post add(String subject, String text, int topic_id, int user_id) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ String queryString = "INSERT INTO posts (subject, text, topic_id, user_id) VALUES " +
+ "(\"" + subject + "\", \"" + text + "\", " + topic_id + ", " + user_id + ");";
+ System.out.println(queryString);
+ stmt.executeUpdate(queryString);
+
+ queryString = "UPDATE users SET post_count=post_count+1 WHERE user_id=" + user_id + ";";
+ stmt.executeUpdate(queryString);
+
+ stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM posts WHERE topic_id=" + topic_id +
+ " AND user_id=" + user_id + " AND subject=\"" + subject + "\";");
+ rs.first();
+
+ Post result = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
+ rs.getInt("topic_id"), rs.getInt("user_id"));
+
+ con.close();
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public boolean delete(int post_id) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ Post post = get(post_id);
+
+ stmt.executeUpdate("DELETE FROM posts WHERE post_id=" + post_id + ";");
+ stmt.executeUpdate("UPDATE users SET post_count=post_count-1 WHERE user_id=" + post.user_id + ";");
+
+ con.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public boolean update(Post post) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ String queryString = "UPDATE posts SET subject=\"" + post.subject + "\", text=\"" + post.text +
+ "\" WHERE post_id=" + post.post_id + ";";
+ System.out.println(queryString);
+ stmt.executeUpdate(queryString);
+
+ con.close();
+
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
}
\ No newline at end of file
Deleted: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ThreadDAO.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -1,5 +0,0 @@
-package prc.bubulina.forum.data_access;
-
-public class ThreadDAO {
-
-}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -1,5 +1,95 @@
package prc.bubulina.forum.data_access;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+
+import prc.bubulina.forum.dataclasses.ForumThread;
+import prc.bubulina.forum.dataclasses.Post;
+import prc.bubulina.forum.dataclasses.Topic;
+
public class TopicDAO {
+ public Topic get(int topic_id) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM topics WHERE topic_id=\"" + topic_id + "\"");
+ rs.first();
+
+ Topic result = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"));
+
+ con.close();
+
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ public Topic add(String subject, ForumThread thread) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ String queryString = "INSERT INTO topics (subject, thread_id) VALUES " +
+ "(\"" + subject + "\", \"" + thread.thread_id + "\");";
+ System.out.println(queryString);
+ stmt.executeUpdate(queryString);
+
+ queryString = "UPDATE threads SET topic_count=topic_count+1 WHERE thread_id=" + thread.thread_id + ";";
+ stmt.executeUpdate(queryString);
+
+ stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM topics WHERE subject=\"" + subject + "\"" +
+ " AND thread_id=\"" + thread.thread_id + "\";");
+ rs.first();
+
+ Topic result = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"));
+
+ con.close();
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public boolean delete(int topic_id) {
+ try {
+ Topic topic = get(topic_id);
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ stmt.executeUpdate("DELETE FROM topics WHERE topic_id=\"" + topic_id + "\"");
+ stmt.executeUpdate("UPDATE threads SET topic_count=topic_count-1 WHERE thread_id=" + topic.thread_id + ";");
+
+ con.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public List<Post> getPosts(int topic_id) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * from posts WHERE topic_id=" + topic_id);
+
+ List<Post> result = new LinkedList<Post>();
+ while (rs.next()) {
+ Post t = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
+ rs.getInt("topic_id"), rs.getInt("user_id"));
+ result.add(t);
+ }
+ return result;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -3,7 +3,10 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+import prc.bubulina.forum.dataclasses.Post;
import prc.bubulina.forum.dataclasses.User;
public class UserDAO {
@@ -26,36 +29,37 @@
return null;
}
- public boolean add(String name, String password, String email) {
+ public User add(String name, String password, String email) {
try {
Connection con = ForumDAOFactory.createConnection();
Statement stmt = con.createStatement();
- String queryString = "INSERT INTO users (name, password, email, post_count, joined_date) " +
+ String queryString = "INSERT INTO users (name, password, email, joined_date) " +
"VALUES (\"" + name + "\", \"" + password + "\", \"" +
- email + "\", 0, CURDATE());";
+ email + "\", CURDATE());";
System.out.println(queryString);
stmt.executeUpdate(queryString);
con.close();
- return true;
+ return get(name);
} catch (Exception e) {
e.printStackTrace();
}
- return false;
+ return null;
}
- public boolean update(User user, String name, String password, String email) {
+ public boolean update(User user) {
try {
Connection con = ForumDAOFactory.createConnection();
Statement stmt = con.createStatement();
- String queryString = "UPDATE users SET name=\"" + name + "\", password=\"" + password + "\", " +
- "email=\"" + email + "\" WHERE user_id=" + user.user_id + ";";
+ String queryString = "UPDATE users SET name=\"" + user.name + "\", password=\"" + user.password + "\", " +
+ "email=\"" + user.email + "\" WHERE user_id=" + user.user_id + ";";
System.out.println(queryString);
stmt.executeUpdate(queryString);
con.close();
+
return true;
} catch (Exception e) {
e.printStackTrace();
@@ -96,4 +100,38 @@
}
return false;
}
+
+ public boolean delete(int user_id) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement();
+
+ stmt.executeUpdate("DELETE FROM users WHERE user_id=\"" + user_id + "\"");
+
+ con.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public List<Post> getPosts(int user_id) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * from posts WHERE user_id=" + user_id);
+
+ List<Post> result = new LinkedList<Post>();
+ while (rs.next()) {
+ Post t = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
+ rs.getInt("topic_id"), rs.getInt("user_id"));
+ result.add(t);
+ }
+ return result;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
\ No newline at end of file
Copied: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/ForumThread.java (from rev 140, JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java)
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/ForumThread.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/ForumThread.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -0,0 +1,17 @@
+package prc.bubulina.forum.dataclasses;
+
+public class ForumThread {
+ public int thread_id;
+ public String name;
+ public int topic_count;
+
+ public ForumThread(int thread_id, String name, int topic_count) {
+ this.thread_id = thread_id;
+ this.name = name;
+ this.topic_count = topic_count;
+ }
+
+ public String toString() {
+ return "ID: " + thread_id + " name: " + name + " Topics: " + topic_count;
+ }
+}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -14,4 +14,8 @@
this.topic_id = topic_id;
this.user_id = user_id;
}
+
+ public String toString() {
+ return "ID: " + post_id + " Subject: " + subject + " Text: " + text + " TopicID: " + topic_id + " UserID: " + user_id;
+ }
}
\ No newline at end of file
Deleted: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Thread.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -1,13 +0,0 @@
-package prc.bubulina.forum.dataclasses;
-
-public class Thread {
- public int thread_id;
- public String name;
- public int topic_count;
-
- public Thread(int thread_id, String name, int topic_count) {
- this.thread_id = thread_id;
- this.name = name;
- this.topic_count = topic_count;
- }
-}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -10,4 +10,8 @@
this.subject = subject;
this.thread_id = thread_id;
}
+
+ public String toString() {
+ return "ID: " + topic_id + " Subject: " + subject + " ThreadID: " + thread_id;
+ }
}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/User.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -18,4 +18,9 @@
this.post_count = post_count;
this.joined_date = joined_date;
}
+
+ public String toString() {
+ return "ID: " + user_id + " Name: " + name + " Password: " + password + " email: " + email +
+ " Posts: " + post_count + " Joined: " + joined_date;
+ }
}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java 2010-05-14 12:00:51 UTC (rev 141)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java 2010-05-14 17:02:08 UTC (rev 142)
@@ -1,14 +1,23 @@
package prc.bubulina.forum.test;
+import java.util.List;
+
import prc.bubulina.forum.data_access.ForumDAOFactory;
+import prc.bubulina.forum.data_access.ForumThreadDAO;
+import prc.bubulina.forum.data_access.PostDAO;
+import prc.bubulina.forum.data_access.TopicDAO;
import prc.bubulina.forum.data_access.UserDAO;
+import prc.bubulina.forum.dataclasses.ForumThread;
+import prc.bubulina.forum.dataclasses.Post;
+import prc.bubulina.forum.dataclasses.Topic;
import prc.bubulina.forum.dataclasses.User;
public class Test {
public static void main(String[] args) {
+ /*
UserDAO userDao= ForumDAOFactory.getUserDAO();
- //userDao.add("Horia", "bubulina", "hor...@gm...");
+ userDao.add("gicu", "bubulina", "hor...@gm...");
User user = userDao.get("Horia");
System.out.println(user.post_count + " " + user.password + " " + user.email);
@@ -17,6 +26,68 @@
userDao.update(user, "Horia", "hdsuahda", "h0...@ya...");
- //userDao.delete("Horia");
+ userDao.delete("Horia");
+
+ /*
+ ForumThreadDAO threadDao = ForumDAOFactory.getThreadDAO();
+ threadDao.add("thread15");
+
+ ForumThread thread = threadDao.get("thread15");
+ System.out.println(thread.thread_id + " " + thread.name + " " + thread.topic_count);
+
+ threadDao.delete("thread15");
+
+ ForumThreadDAO threadDao = ForumDAOFactory.getThreadDAO();
+ ForumThread thread = threadDao.get("thread15");
+ TopicDAO topicDao = ForumDAOFactory.getTopicDAO();
+ //topicDao.add("topic1", thread);
+
+ Topic topic = topicDao.get("topic1");
+ System.out.println(topic.subject + " " + topic.topic_id + " " + topic.thread_id);
+
+ //topicDao.delete("topic1");
+ */
+ UserDAO userdao = ForumDAOFactory.getUserDAO();
+ ForumThreadDAO threaddao = ForumDAOFactory.getThreadDAO();
+ TopicDAO topicdao = ForumDAOFactory.getTopicDAO();
+ PostDAO postdao = ForumDAOFactory.getPostDAO();
+
+ //User u = userdao.add("zozo", "inimini", "xm...@ho...");
+ //System.out.println(u);
+
+ User u = userdao.get("Horia");
+ System.out.println(u);
+
+ System.out.println(userdao.checkPassword("zozo", "inimini"));
+
+ u.email = "hor...@gm...";
+ userdao.update(u);
+
+ //userdao.delete("zozo");
+
+ //ForumThread thread = threaddao.add("thread1");
+ //System.out.println(thread);
+
+ ForumThread thread = threaddao.get("thread1");
+ System.out.println(thread);
+
+ //topicdao.add("s1", thread);
+ //topicdao.add("s2", thread);
+ //topicdao.add("s3", thread);
+ List<Topic> list = threaddao.getTopics("thread1");
+ System.out.println(list);
+
+ //postdao.add("subje1", "ana are mere", list.get(0).topic_id, u.user_id);
+ //postdao.add("subje2", "bubu are pere", list.get(0).topic_id, u.user_id);
+
+ List<Post> posts = topicdao.getPosts(list.get(0).topic_id);
+ System.out.println(posts);
+
+ Post p = posts.get(1);
+ System.out.println(p);
+ p.text = "jijisjdasi";
+ postdao.update(p);
+
+ postdao.delete(p.post_id);
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-16 16:13:00
|
Revision: 144
http://cruce.svn.sourceforge.net/cruce/?rev=144&view=rev
Author: alinposho
Date: 2010-05-16 16:12:53 +0000 (Sun, 16 May 2010)
Log Message:
-----------
Am incercat sa fac prma pagina dar bu stiu de ce cand rulez pe server nu se conecteaza la baza de date si imi arunca o excetie.
Aveti vreo idee?
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/index.jsp
Added Paths:
-----------
JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/
JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-16 14:28:29 UTC (rev 143)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-16 16:12:53 UTC (rev 144)
@@ -1,12 +1,60 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
+ pageEncoding="ISO-8859-1"
+ %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
+
+<%@page import="prc.bubulina.forum.data_access.ForumThreadDAO"%>
+<%@page import="prc.bubulina.forum.businessLogic.Singleton"%>
+<%@page import="prc.bubulina.forum.dataclasses.ForumThread"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Insert title here</title>
+<title>Team Bubulina's Forum</title>
+<style type="text/css">
+<!--
+ table
+ {
+ border="10";
+ bordercolor="blue";
+ align="center";
+ width="80%"
+ }
+
+ a:link {color: green;
+ background: red}
+
+ h1 {font-weight: bold;
+ text-align: center;}
+-->
+</style>
</head>
<body>
+<div>
+<table>
+ <caption align="top">The threads running on this forum are:</caption>
+ <tr>
+ <th>Thread name</th>
+ <th>Topic count</th>
+ </tr>
+ <% ForumThreadDAO threads = Singleton.getInstance().getThreadDAO();
+ out.println("Something happend");
+ for(ForumThread thread : threads.getAllThreads())
+ {%>
+ <%out.println("Something happend"); %>
+ <tr>
+ <td>
+ <%
+ out.print(thread.name);
+ %>
+ </td>
+ <td>
+ <%
+ out.print(thread.topic_count);
+ %>
+ </td>
+ </tr>
+ <%}%>
+</table>
+</div>
</body>
</html>
\ No newline at end of file
Added: JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java (rev 0)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java 2010-05-16 16:12:53 UTC (rev 144)
@@ -0,0 +1,31 @@
+package prc.bubulina.forum.businessLogic;
+
+import prc.bubulina.forum.data_access.ForumDAOFactory;
+import prc.bubulina.forum.data_access.ForumThreadDAO;
+
+public class Singleton
+{
+ private ForumThreadDAO threadDAO;
+ private static Singleton instance = null;
+
+ private Singleton()
+ {
+ threadDAO = ForumDAOFactory.getThreadDAO();
+ }
+
+ public static Singleton getInstance()
+ {
+ if(instance == null)
+ {
+ instance = new Singleton();
+ }
+
+ return instance;
+ }
+
+ public ForumThreadDAO getThreadDAO()
+ {
+ return threadDAO;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ca...@us...> - 2010-05-16 17:54:34
|
Revision: 146
http://cruce.svn.sourceforge.net/cruce/?rev=146&view=rev
Author: caiusb
Date: 2010-05-16 17:54:25 +0000 (Sun, 16 May 2010)
Log Message:
-----------
Modified Paths:
--------------
JSP/trunk/Forum/.classpath
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
Removed Paths:
-------------
JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java
JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java
Property Changed:
----------------
JSP/trunk/Forum/WebContent/WEB-INF/lib/
Modified: JSP/trunk/Forum/.classpath
===================================================================
--- JSP/trunk/Forum/.classpath 2010-05-16 17:02:34 UTC (rev 145)
+++ JSP/trunk/Forum/.classpath 2010-05-16 17:54:25 UTC (rev 146)
@@ -1,8 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre"/>
- <classpathentry kind="output" path="build/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-sun-1.6.0.20">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="lib" path="/home/caius/apache-tomcat-6.0.26/lib/servlet-api.jar"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Property changes on: JSP/trunk/Forum/WebContent/WEB-INF/lib
___________________________________________________________________
Added: svn:ignore
+ *.jar
Deleted: JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java 2010-05-16 17:02:34 UTC (rev 145)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/Hello.java 2010-05-16 17:54:25 UTC (rev 146)
@@ -1,7 +0,0 @@
-package prc.bubulina.forum;
-
-public class Hello {
- public String getHello() {
- return "Hello, World!";
- }
-}
Deleted: JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java 2010-05-16 17:02:34 UTC (rev 145)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/HelloServlet.java 2010-05-16 17:54:25 UTC (rev 146)
@@ -1,40 +0,0 @@
-package prc.bubulina.forum;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Servlet implementation class HelloServlet
- */
-public class HelloServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private Hello hello;
-
- /**
- * Default constructor.
- */
- public HelloServlet() {
- hello = new Hello();
- }
-
- /**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- PrintWriter out = response.getWriter();
- out.println("Hello, World!");
- }
-
- /**
- * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- }
-
-}
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java 2010-05-16 17:02:34 UTC (rev 145)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java 2010-05-16 17:54:25 UTC (rev 146)
@@ -10,7 +10,7 @@
public static Connection createConnection() {
try {
- Class.forName("com.mysql.jdbc.Driver");
+ Class.forName(DRIVER);
return DriverManager.getConnection(DBURL, "horia", "barcelona");
} catch (Exception e) {
e.printStackTrace();
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java 2010-05-16 17:02:34 UTC (rev 145)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java 2010-05-16 17:54:25 UTC (rev 146)
@@ -52,10 +52,10 @@
TopicDAO topicdao = ForumDAOFactory.getTopicDAO();
PostDAO postdao = ForumDAOFactory.getPostDAO();
- //User u = userdao.add("zozo", "inimini", "xm...@ho...");
- //System.out.println(u);
+ User u = userdao.add("zozo", "inimini", "xm...@ho...");
+ System.out.println(u);
- User u = userdao.get("Horia");
+ u = userdao.get("zozo");
System.out.println(u);
System.out.println(userdao.checkPassword("zozo", "inimini"));
@@ -63,22 +63,22 @@
u.email = "hor...@gm...";
userdao.update(u);
- //userdao.delete("zozo");
+ userdao.delete("zozo");
- //ForumThread thread = threaddao.add("thread1");
- //System.out.println(thread);
+ ForumThread thread = threaddao.add("thread1");
+ System.out.println(thread);
- ForumThread thread = threaddao.get("thread1");
+ thread = threaddao.get("thread1");
System.out.println(thread);
- //topicdao.add("s1", thread);
- //topicdao.add("s2", thread);
- //topicdao.add("s3", thread);
+ topicdao.add("s1", thread);
+ topicdao.add("s2", thread);
+ topicdao.add("s3", thread);
List<Topic> list = threaddao.getTopics("thread1");
System.out.println(list);
- //postdao.add("subje1", "ana are mere", list.get(0).topic_id, u.user_id);
- //postdao.add("subje2", "bubu are pere", list.get(0).topic_id, u.user_id);
+ postdao.add("subje1", "ana are mere", list.get(0).topic_id, u.user_id);
+ postdao.add("subje2", "bubu are pere", list.get(0).topic_id, u.user_id);
List<Post> posts = topicdao.getPosts(list.get(0).topic_id);
System.out.println(posts);
@@ -88,6 +88,6 @@
p.text = "jijisjdasi";
postdao.update(p);
- postdao.delete(p.post_id);
+ //postdao.delete(p.post_id);
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ca...@us...> - 2010-05-17 14:00:40
|
Revision: 148
http://cruce.svn.sourceforge.net/cruce/?rev=148&view=rev
Author: caiusb
Date: 2010-05-17 14:00:33 +0000 (Mon, 17 May 2010)
Log Message:
-----------
Am implementat o parte din index. Daca dai click pe un thread, te duce la continutul lui. In pagina Thread.jsp se afiseaza toate topic-urile care apartin de acel thread. Momentan nu exista pagina Topic.jsp, asa ca o sa dea eroare daca dati click.
Am modificat si pe ForumThreadDAO ca sa obtin thread-ul si lista topic-urilor si dupa id nu doar dupa nume. E mult mai usor si mai logic asa.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/Thread.jsp
JSP/trunk/Forum/WebContent/index.jsp
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java
Modified: JSP/trunk/Forum/WebContent/Thread.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-16 18:55:14 UTC (rev 147)
+++ JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-17 14:00:33 UTC (rev 148)
@@ -1,12 +1,56 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@page import="prc.bubulina.forum.data_access.TopicDAO"%>
+<%@page import="prc.bubulina.forum.data_access.ForumThreadDAO"%>
+<%@page import="prc.bubulina.forum.dataclasses.ForumThread"%>
+<%@page import="prc.bubulina.forum.businessLogic.Singleton"%>
+<%@page import="prc.bubulina.forum.dataclasses.Topic"%>
+<%@page import="java.util.*" %>
+<% %>
+
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Insert title here</title>
+<%
+ String sID = request.getParameter("id");
+ int id = Integer.parseInt(sID);
+ ForumThread thread = Singleton.getInstance().getThreadDAO().get(id);
+%>
+<title>Forum Bubulina: <% out.println(thread.name); %></title>
</head>
<body>
+<div>
+<table>
+ <caption align="top">Topics in this thread are:</caption>
+ <tr>
+ <th>Topic name</th>
+ <th>Post count</th>
+ </tr>
+ <%
+ List<Topic> topics = Singleton.getInstance().getThreadDAO().getTopics(id);
+ for(Topic t:topics) {
+ %>
+ <tr>
+ <td>
+ <a href=Topic.jsp?id=<%= t.topic_id %>>
+ <%
+ out.print(t.subject);
+ %>
+ </a>
+ </td>
+ <td>
+ <%
+ out.print("0");
+ %>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+</table>
+</div>
</body>
</html>
\ No newline at end of file
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-16 18:55:14 UTC (rev 147)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-17 14:00:33 UTC (rev 148)
@@ -4,7 +4,9 @@
<%@page import="prc.bubulina.forum.data_access.ForumThreadDAO"%>
<%@page import="prc.bubulina.forum.businessLogic.Singleton"%>
-<%@page import="prc.bubulina.forum.dataclasses.ForumThread"%><html>
+<%@page import="prc.bubulina.forum.dataclasses.ForumThread"%>
+
+<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Team Bubulina's Forum</title>
@@ -35,17 +37,15 @@
</tr>
<%
ForumThreadDAO threads = Singleton.getInstance().getThreadDAO();
- //out.println("Something happend");
for (ForumThread thread : threads.getAllThreads()) {
%>
- <%
- //out.println("Something happend");
- %>
<tr>
<td>
+ <a href=Thread.jsp?id=<%= thread.thread_id %>>
<%
out.print(thread.name);
%>
+ </a>
</td>
<td>
<%
@@ -58,6 +58,7 @@
%>
</table>
</div>
-
+<p>
+</p>
</body>
</html>
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java 2010-05-16 18:55:14 UTC (rev 147)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java 2010-05-17 14:00:33 UTC (rev 148)
@@ -28,6 +28,25 @@
return null;
}
+ public ForumThread get(int threadID) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM threads WHERE thread_id=\"" + threadID + "\"");
+ rs.first();
+
+ ForumThread result = new ForumThread(rs.getInt("thread_id"), rs.getString("name"), rs.getInt("topic_count"));
+
+ con.close();
+
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
public ForumThread add(String name) {
try {
Connection con = ForumDAOFactory.createConnection();
@@ -83,6 +102,25 @@
return null;
}
+ public List<Topic> getTopics(int threadID) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * from topics WHERE thread_id=" + threadID);
+
+ List<Topic> result = new LinkedList<Topic>();
+ while (rs.next()) {
+ Topic t = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"));
+ result.add(t);
+ }
+ return result;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
public List<ForumThread> getAllThreads() {
try {
Connection con = ForumDAOFactory.createConnection();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ca...@us...> - 2010-05-17 16:29:14
|
Revision: 149
http://cruce.svn.sourceforge.net/cruce/?rev=149&view=rev
Author: caiusb
Date: 2010-05-17 16:29:08 +0000 (Mon, 17 May 2010)
Log Message:
-----------
Am implementat si afisearea topic-urilor si a posturilor dintr-un topic. Arata ca ceapa, stiu, dar cand o sa avem css-ul o sa fie mult mai fain :D
Macar merge si face ce trebe.
O sa-l pun in cateva minute si pe server.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/Thread.jsp
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
Added Paths:
-----------
JSP/trunk/Forum/WebContent/Topic.jsp
Modified: JSP/trunk/Forum/WebContent/Thread.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-17 14:00:33 UTC (rev 148)
+++ JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-17 16:29:08 UTC (rev 149)
@@ -8,7 +8,6 @@
<%@page import="prc.bubulina.forum.businessLogic.Singleton"%>
<%@page import="prc.bubulina.forum.dataclasses.Topic"%>
<%@page import="java.util.*" %>
-<% %>
<html>
<head>
@@ -18,7 +17,7 @@
int id = Integer.parseInt(sID);
ForumThread thread = Singleton.getInstance().getThreadDAO().get(id);
%>
-<title>Forum Bubulina: <% out.println(thread.name); %></title>
+<title>Forum Bubulina: Thread - <% out.println(thread.name); %></title>
</head>
<body>
<div>
Added: JSP/trunk/Forum/WebContent/Topic.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Topic.jsp (rev 0)
+++ JSP/trunk/Forum/WebContent/Topic.jsp 2010-05-17 16:29:08 UTC (rev 149)
@@ -0,0 +1,58 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@page import="prc.bubulina.forum.data_access.TopicDAO"%>
+<%@page import="prc.bubulina.forum.data_access.UserDAO"%>
+<%@page import="prc.bubulina.forum.data_access.ForumDAOFactory"%>
+<%@page import="prc.bubulina.forum.dataclasses.Post"%>
+<%@page import="prc.bubulina.forum.dataclasses.Topic"%>
+<%@page import="prc.bubulina.forum.dataclasses.User"%>
+<%@page import="java.util.*" %>
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<%
+ String sID = request.getParameter("id");
+ int id = Integer.parseInt(sID);
+ TopicDAO topicDAO = ForumDAOFactory.getTopicDAO();
+ Topic topic = topicDAO.get(id);
+%>
+<title>Forum Bubulina: Topic - <% out.println(topic.subject); %></title>
+</head>
+<body>
+<div>
+<table border="1">
+ <caption align="top">The posts this topic are:</caption>
+ <%
+ List<Post> posts = topicDAO.getPosts(id);
+ UserDAO userDAO = ForumDAOFactory.getUserDAO();
+ for(Post p:posts) {
+ %>
+ <tr>
+ <th>User info</th>
+ <th>Subject: <% out.println(p.subject); %></th>
+ </tr>
+ <tr>
+ <%
+ User user = userDAO.get(p.user_id);
+ %>
+ <td>
+ Name: <% out.println(user.name); %> <br/>
+ Post count: <% out.println(user.post_count); %> <br/>
+ Joined: <% out.println(user.joined_date.toLocaleString()); %> <br/>
+ </td>
+ <td>
+ <%
+ out.println(p.text);
+ %>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+</table>
+</div>
+</body>
+</html>
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-17 14:00:33 UTC (rev 148)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-17 16:29:08 UTC (rev 149)
@@ -29,6 +29,25 @@
return null;
}
+ public User get(int userID) {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE user_id=\"" + userID + "\"");
+ rs.first();
+
+ User result = new User(rs.getInt("user_id"), rs.getString("name"), rs.getString("password"), rs.getString("email"),
+ rs.getInt("post_count"), rs.getDate("joined_date"));
+
+ con.close();
+
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
public User add(String name, String password, String email) {
try {
Connection con = ForumDAOFactory.createConnection();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ca...@us...> - 2010-05-17 18:07:39
|
Revision: 151
http://cruce.svn.sourceforge.net/cruce/?rev=151&view=rev
Author: caiusb
Date: 2010-05-17 18:07:33 +0000 (Mon, 17 May 2010)
Log Message:
-----------
Am pus post_count si in scriptul pentru baza de date.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/Thread.jsp
JSP/trunk/Forum/bd_script.sql
Modified: JSP/trunk/Forum/WebContent/Thread.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-17 16:41:38 UTC (rev 150)
+++ JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-17 18:07:33 UTC (rev 151)
@@ -41,7 +41,7 @@
</td>
<td>
<%
- out.print("0");
+ out.print(t.post_count);
%>
</td>
</tr>
Modified: JSP/trunk/Forum/bd_script.sql
===================================================================
--- JSP/trunk/Forum/bd_script.sql 2010-05-17 16:41:38 UTC (rev 150)
+++ JSP/trunk/Forum/bd_script.sql 2010-05-17 18:07:33 UTC (rev 151)
@@ -25,6 +25,7 @@
topic_id INT NOT NULL AUTO_INCREMENT,
subject VARCHAR(30) NOT NULL,
thread_id INT NOT NULL,
+ post_count INT NOT NULL DEFAULT 0,
PRIMARY KEY (topic_id),
FOREIGN KEY (thread_id) REFERENCES threads(thread_id) ON DELETE CASCADE
);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-18 08:38:51
|
Revision: 152
http://cruce.svn.sourceforge.net/cruce/?rev=152&view=rev
Author: alinposho
Date: 2010-05-18 08:38:40 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Am schimbat putin pagina de index si am adugat paginile pentru register si login.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/Thread.jsp
JSP/trunk/Forum/WebContent/index.jsp
JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java
Added Paths:
-----------
JSP/trunk/Forum/WebContent/commitRegister.jsp
JSP/trunk/Forum/WebContent/login.jsp
JSP/trunk/Forum/WebContent/register.jsp
Modified: JSP/trunk/Forum/WebContent/Thread.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-17 18:07:33 UTC (rev 151)
+++ JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-18 08:38:40 UTC (rev 152)
@@ -15,7 +15,7 @@
<%
String sID = request.getParameter("id");
int id = Integer.parseInt(sID);
- ForumThread thread = Singleton.getInstance().getThreadDAO().get(id);
+ ForumThread thread = Singleton.getInstance().getThreadDAO().get(id);;
%>
<title>Forum Bubulina: Thread - <% out.println(thread.name); %></title>
</head>
Added: JSP/trunk/Forum/WebContent/commitRegister.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/commitRegister.jsp (rev 0)
+++ JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 08:38:40 UTC (rev 152)
@@ -0,0 +1,99 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@page import="prc.bubulina.forum.data_access.UserDAO"%>
+<%@page import="prc.bubulina.forum.businessLogic.Singleton"%><html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+<body>
+
+<%
+ //checking the validity of the fields
+ UserDAO userDAO = Singleton.getInstance().getUserDAO();
+ String userName = request.getParameter("userName");
+ String password = request.getParameter("password");
+ String checkPassword = request.getParameter("checkPassword");
+ String email = request.getParameter("email");
+ String problem = null;
+ if(userName == null || userName.isEmpty() || userName.equals("null") ||
+ (userDAO.get(userName) != null))
+ {
+ problem = "Wrong userName!";
+ }
+ else
+ {
+ if(password == null || password.isEmpty() || password.equals("null"))
+ {
+ problem = "null or empty password!";
+ }
+ else
+ {
+ if(checkPassword == null || checkPassword.isEmpty() || checkPassword.equals("null"))
+ {
+ problem = "null or empty password retyper!";
+ }
+ else
+ {
+ if(password.equals(checkPassword) == false)
+ {
+ problem = "Please retype password!";
+ }
+ else
+ {
+ if(email == null || email.isEmpty() || email.equals("null"))
+ {
+ problem = "null or empty email!";
+ }
+ }
+ }
+ }
+ }
+ if(problem != null)
+ {
+ %>
+ <!-- Forwarding problem -->
+ <form name="dummy2">
+ <input type="hidden" name="problem" value="<%out.print(problem);%>"
+ >
+ </form>
+ <jsp:forward page="register.jsp"></jsp:forward>
+ <%
+ }
+ if(userDAO.add(userName, password, email) == null)
+ {
+ %>
+ <script type="text/javascript">
+ alert("Problem registering user! Please try again");
+ </script>
+ <input type="hidden" name="problem" value="<% out.print(problem);%>"
+ >
+ <jsp:forward page="register.jsp"></jsp:forward>
+ <%
+
+ }
+ else
+ {
+ %>
+ <p>
+ Congratulations <%out.print(userName);%>. You have been successfully registered.
+ </p>
+ <form action="index.jsp" method="post">
+ <input type="submit" value="Back to main">
+ </form>
+ <!-- Forwarding user name -->
+ <form name="dummy">
+ <input type="hidden" name="user"
+ value="<%out.print(userName); %>"
+ >
+ </form>
+
+ <%
+
+ }
+
+%>
+</body>
+</html>
\ No newline at end of file
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-17 18:07:33 UTC (rev 151)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 08:38:40 UTC (rev 152)
@@ -11,32 +11,127 @@
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Team Bubulina's Forum</title>
<style type="text/css">
-table,th,td {
- border: 1px solid blue;
+
+table{
+ border: 10px solid blue;
border-collapse: collapse;
+ align: center;
+ width: 80%
}
+th{
+ align: center;
+}
+td{
+ border: 3px solid blue;
+ border-collapse: collapse;
+ height: 40px;
+}
+
a:link {
- color: green;
- background: red
+ color: green;
}
h1 {
font-weight: bold;
text-align: center;
}
+
+#leftContent {
+ float: left;
+ padding: 10px;
+ width: 300px; /* ie5win fudge begins */
+ voice-family: "\"}\"";
+ voice-family:inherit;
+ width: 270px;
+ }
+html>body #leftContent {
+ width: 270px; /* ie5win fudge ends */
+ }
+#rigthContent {
+ float: left;
+ padding: 10px;
+ width: 300px; /* ie5win fudge begins */
+ voice-family: "\"}\"";
+ voice-family:inherit;
+ width: 270px;
+ }
+html>body #rigthContent {
+ width: 270px; /* ie5win fudge ends */
+ }
</style>
</head>
<body>
+
+<%
+ //This form is to be dispayed only if the user is logged in
+ String user = request.getParameter("user");
+ if(user != null && !user.equalsIgnoreCase("null"))
+ {
+%>
+ <!-- The form for adding a new Thread -->
+ <div id="leftContent" align="right">
+ <FORM NAME="AddThread" action="index.jsp" method="get">
+ Thread name: <INPUT TYPE="TEXT" NAME="ThreadName" value="">
+ <INPUT TYPE="submit" VALUE="Add Thread">
+ </FORM>
+ </div>
+
+<%
+ //If the user has logged in
+ %>
+ <p> Hello <%out.print(user); %>!</p>
+ <%
+ }
+ else
+ {
+ %>
+
+ <div id="#rigthContent" align="right" >
+ <form name="LoginForm" action="login.jsp" method="post">
+ User name: <input type="text" name="username"><br>
+ Password: <input type="password" name="password"><br>
+ <input type="submit" value="login">
+ <%
+ //Handling posible login problems
+ String problem = request.getParameter("problem");
+ if(problem != null && (problem.isEmpty() == false)
+ && (problem.equals("null")) == false)
+ {
+ %>
+ <font color="red" size="14">
+ There is the following problem: <%out.println(problem); %>
+ </font>
+ <%
+ }
+ %>
+ </form>
+ <form action="register.jsp" action=post>
+ <input type="submit" value="register">
+ </form>
+ </div>
+<% }
+%>
+
+<!-- The actual table with threads -->
+
<div>
-<table>
- <caption align="top">The threads running on this forum are:</caption>
+<table align = center>
+ <caption align="top">The threads running on this forum are:<br></caption>
<tr>
<th>Thread name</th>
<th>Topic count</th>
</tr>
<%
ForumThreadDAO threads = Singleton.getInstance().getThreadDAO();
+
+ //Checking for a thread that was added in the previous page
+ String threadName = request.getParameter("ThreadName");
+ if(threadName != null && !threadName.equals(""))
+ {
+ threads.add(threadName);
+ }
+
for (ForumThread thread : threads.getAllThreads()) {
%>
<tr>
@@ -58,6 +153,13 @@
%>
</table>
</div>
+
+<!-- Forwarding user name -->
+<form name="dummy">
+<input type="hidden" name="user"
+ value="<%request.getParameter("user"); %>"
+ >
+</form>
<p>
</p>
</body>
Added: JSP/trunk/Forum/WebContent/login.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/login.jsp (rev 0)
+++ JSP/trunk/Forum/WebContent/login.jsp 2010-05-18 08:38:40 UTC (rev 152)
@@ -0,0 +1,75 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<%@page import="prc.bubulina.forum.data_access.UserDAO"%>
+<%@page import="prc.bubulina.forum.businessLogic.Singleton"%>
+<%@page import="prc.bubulina.forum.dataclasses.*"%>
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+<body>
+ <%
+ //checking the validity of the fields
+ UserDAO userDAO = Singleton.getInstance().getUserDAO();
+ String userName = request.getParameter("username");
+ String password = request.getParameter("password");
+ String problem = null;
+ User userToLoggin = null;
+ if(userName == null || userName.isEmpty() || userName.equals("null"))
+ {
+ problem = "Wrong userName!";
+ }
+ else
+ {
+ if(password == null || password.isEmpty() || password.equals("null"))
+ {
+ problem = "null or empty password!";
+ }
+ else
+ {
+ userToLoggin = userDAO.get(userName);
+ if(userToLoggin == null ||
+ userToLoggin.password.equals(password) == false)
+ {
+ problem = "Wrong username or password!";
+ }
+ }
+ }
+ if(problem != null)
+ {
+ %>
+ <!-- Forwarding problem -->
+ <form name="dummy2">
+ <input type="hidden" name="problem" value="<%out.print(problem);%>"
+ >
+ </form>
+ <jsp:forward page="index.jsp"></jsp:forward>
+ <%
+ }
+ else
+ {
+ //All OK
+ %>
+ <p>
+ Congratulations <%out.print(userName);%>. You have been successfully logged in.
+ </p>
+ <form action="index.jsp" method="post">
+ <input type="submit" value="Back to main">
+ </form>
+ <!-- Forwarding user name -->
+ <form name="dummy">
+ <input type="hidden" name="user"
+ value="<%request.getParameter("username");%>"
+ >
+ </form>
+
+ <%
+ }
+%>
+
+</body>
+</html>
\ No newline at end of file
Added: JSP/trunk/Forum/WebContent/register.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/register.jsp (rev 0)
+++ JSP/trunk/Forum/WebContent/register.jsp 2010-05-18 08:38:40 UTC (rev 152)
@@ -0,0 +1,76 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Register</title>
+
+<style type="text/css">
+
+
+td
+{
+
+}
+</style>
+
+
+</head>
+<body>
+ <%
+ String problem = request.getParameter("problem");
+ if(problem != null && (problem.isEmpty() == false)
+ && (problem.equals("null")) == false)
+ {
+ %>
+ <font color="red" size="14">
+ There is the following problem: <%out.println(problem); %>
+ </font>
+ <%
+ }
+ %>
+ <form name="register" action="commitRegister.jsp" method="post">
+ <table align="center" width="80%">
+ <tr>
+ <td align="right">
+ User name:
+ </td>
+ <td>
+ <input type="text" value="" name="userName">
+ </td>
+ </tr>
+ <tr>
+ <td align="right">
+ password:
+ </td>
+ <td>
+ <input type="password" value="" name="password">
+ </td>
+ </tr>
+ <tr>
+ <td align="right">
+ Retype Password:
+ </td>
+ <td>
+ <input type="password" value="" name="checkPassword">
+ </td>
+ </tr>
+ <tr>
+ <td align="right">
+ Email:
+ </td>
+ <td>
+ <input type="text" value="" name="email">
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <input type="submit" value="Submit" name="submit">
+ </td>
+ </tr>
+ </table>
+ </form>
+</body>
+</html>
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java 2010-05-17 18:07:33 UTC (rev 151)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java 2010-05-18 08:38:40 UTC (rev 152)
@@ -2,15 +2,18 @@
import prc.bubulina.forum.data_access.ForumDAOFactory;
import prc.bubulina.forum.data_access.ForumThreadDAO;
+import prc.bubulina.forum.data_access.UserDAO;
public class Singleton
{
private ForumThreadDAO threadDAO;
+ private UserDAO users;
private static Singleton instance = null;
private Singleton()
{
threadDAO = ForumDAOFactory.getThreadDAO();
+ users = ForumDAOFactory.getUserDAO();
}
public static Singleton getInstance()
@@ -27,5 +30,9 @@
{
return threadDAO;
}
-
+
+ public UserDAO getUserDAO()
+ {
+ return users;
+ }
}
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java 2010-05-17 18:07:33 UTC (rev 151)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumDAOFactory.java 2010-05-18 08:38:40 UTC (rev 152)
@@ -2,14 +2,13 @@
import java.sql.Connection;
import java.sql.DriverManager;
-import java.sql.SQLException;
public class ForumDAOFactory {
public static final String DRIVER = "com.mysql.jdbc.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/forum";
public static Connection createConnection() {
- try {
+ try {
Class.forName(DRIVER);
return DriverManager.getConnection(DBURL, "horia", "barcelona");
} catch (Exception e) {
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java 2010-05-17 18:07:33 UTC (rev 151)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java 2010-05-18 08:38:40 UTC (rev 152)
@@ -45,7 +45,6 @@
}
return null;
}
-
public ForumThread add(String name) {
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <hor...@us...> - 2010-05-18 10:37:58
|
Revision: 155
http://cruce.svn.sourceforge.net/cruce/?rev=155&view=rev
Author: horiaradu
Date: 2010-05-18 10:37:52 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Am adaugat data la post.
Modified Paths:
--------------
JSP/trunk/Forum/bd_script.sql
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
Modified: JSP/trunk/Forum/bd_script.sql
===================================================================
--- JSP/trunk/Forum/bd_script.sql 2010-05-18 10:02:35 UTC (rev 154)
+++ JSP/trunk/Forum/bd_script.sql 2010-05-18 10:37:52 UTC (rev 155)
@@ -36,6 +36,7 @@
subject VARCHAR(50) NOT NULL,
topic_id INT NOT NULL,
user_id INT NOT NULL,
+ date DATE NOT NULL,
PRIMARY KEY (post_id),
FOREIGN KEY (topic_id) REFERENCES topics(topic_id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-18 10:02:35 UTC (rev 154)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-18 10:37:52 UTC (rev 155)
@@ -15,7 +15,7 @@
rs.first();
Post result = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
con.close();
@@ -31,8 +31,8 @@
Connection con = ForumDAOFactory.createConnection();
Statement stmt = con.createStatement();
- String queryString = "INSERT INTO posts (subject, text, topic_id, user_id) VALUES " +
- "(\"" + subject + "\", \"" + text + "\", " + topic_id + ", " + user_id + ");";
+ String queryString = "INSERT INTO posts (subject, text, topic_id, user_id, date) VALUES " +
+ "(\"" + subject + "\", \"" + text + "\", " + topic_id + ", " + user_id + ", CURDATE());";
System.out.println(queryString);
stmt.executeUpdate(queryString);
@@ -48,7 +48,7 @@
rs.first();
Post result = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
con.close();
return result;
@@ -83,7 +83,7 @@
Statement stmt = con.createStatement();
String queryString = "UPDATE posts SET subject=\"" + post.subject + "\", text=\"" + post.text +
- "\" WHERE post_id=" + post.post_id + ";";
+ "\", date=CURDATE() WHERE post_id=" + post.post_id + ";";
System.out.println(queryString);
stmt.executeUpdate(queryString);
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-18 10:02:35 UTC (rev 154)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-18 10:37:52 UTC (rev 155)
@@ -83,7 +83,7 @@
List<Post> result = new LinkedList<Post>();
while (rs.next()) {
Post t = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
result.add(t);
}
return result;
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-18 10:02:35 UTC (rev 154)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-18 10:37:52 UTC (rev 155)
@@ -144,7 +144,7 @@
List<Post> result = new LinkedList<Post>();
while (rs.next()) {
Post t = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
result.add(t);
}
return result;
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java 2010-05-18 10:02:35 UTC (rev 154)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java 2010-05-18 10:37:52 UTC (rev 155)
@@ -1,21 +1,25 @@
package prc.bubulina.forum.dataclasses;
+import java.sql.Date;
+
public class Post {
public int post_id;
public String subject;
public String text;
public int topic_id;
public int user_id;
+ public Date date;
- public Post(int post_id, String subject, String text, int topic_id, int user_id) {
+ public Post(int post_id, String subject, String text, int topic_id, int user_id, Date date) {
this.post_id = post_id;
this.subject = subject;
this.text = text;
this.topic_id = topic_id;
this.user_id = user_id;
+ this.date = date;
}
public String toString() {
- return "ID: " + post_id + " Subject: " + subject + " Text: " + text + " TopicID: " + topic_id + " UserID: " + user_id;
+ return "ID: " + post_id + " Subject: " + subject + " Text: " + text + " TopicID: " + topic_id + " UserID: " + user_id + " Date: " + date;
}
}
\ No newline at end of file
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java 2010-05-18 10:02:35 UTC (rev 154)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/test/Test.java 2010-05-18 10:37:52 UTC (rev 155)
@@ -63,7 +63,7 @@
u.email = "hor...@gm...";
userdao.update(u);
- userdao.delete("zozo");
+ //userdao.delete("zozo");
ForumThread thread = threaddao.add("thread1");
System.out.println(thread);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <hor...@us...> - 2010-05-18 10:57:49
|
Revision: 156
http://cruce.svn.sourceforge.net/cruce/?rev=156&view=rev
Author: horiaradu
Date: 2010-05-18 10:57:43 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Am adaugat si time.
Modified Paths:
--------------
JSP/trunk/Forum/bd_script.sql
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
Modified: JSP/trunk/Forum/bd_script.sql
===================================================================
--- JSP/trunk/Forum/bd_script.sql 2010-05-18 10:37:52 UTC (rev 155)
+++ JSP/trunk/Forum/bd_script.sql 2010-05-18 10:57:43 UTC (rev 156)
@@ -37,6 +37,7 @@
topic_id INT NOT NULL,
user_id INT NOT NULL,
date DATE NOT NULL,
+ time TIME NOT NULL,
PRIMARY KEY (post_id),
FOREIGN KEY (topic_id) REFERENCES topics(topic_id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-18 10:37:52 UTC (rev 155)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-18 10:57:43 UTC (rev 156)
@@ -15,7 +15,7 @@
rs.first();
Post result = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"), rs.getTime("time"));
con.close();
@@ -31,8 +31,8 @@
Connection con = ForumDAOFactory.createConnection();
Statement stmt = con.createStatement();
- String queryString = "INSERT INTO posts (subject, text, topic_id, user_id, date) VALUES " +
- "(\"" + subject + "\", \"" + text + "\", " + topic_id + ", " + user_id + ", CURDATE());";
+ String queryString = "INSERT INTO posts (subject, text, topic_id, user_id, date, time) VALUES " +
+ "(\"" + subject + "\", \"" + text + "\", " + topic_id + ", " + user_id + ", CURDATE(), CURTIME());";
System.out.println(queryString);
stmt.executeUpdate(queryString);
@@ -48,7 +48,7 @@
rs.first();
Post result = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"), rs.getTime("time"));
con.close();
return result;
@@ -83,7 +83,7 @@
Statement stmt = con.createStatement();
String queryString = "UPDATE posts SET subject=\"" + post.subject + "\", text=\"" + post.text +
- "\", date=CURDATE() WHERE post_id=" + post.post_id + ";";
+ "\", date=CURDATE(), time=CURTIME() WHERE post_id=" + post.post_id + ";";
System.out.println(queryString);
stmt.executeUpdate(queryString);
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-18 10:37:52 UTC (rev 155)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-18 10:57:43 UTC (rev 156)
@@ -83,7 +83,7 @@
List<Post> result = new LinkedList<Post>();
while (rs.next()) {
Post t = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"), rs.getTime("time"));
result.add(t);
}
return result;
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-18 10:37:52 UTC (rev 155)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/UserDAO.java 2010-05-18 10:57:43 UTC (rev 156)
@@ -144,7 +144,7 @@
List<Post> result = new LinkedList<Post>();
while (rs.next()) {
Post t = new Post(rs.getInt("post_id"), rs.getString("subject"), rs.getString("text"),
- rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"));
+ rs.getInt("topic_id"), rs.getInt("user_id"), rs.getDate("date"), rs.getTime("time"));
result.add(t);
}
return result;
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java 2010-05-18 10:37:52 UTC (rev 155)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Post.java 2010-05-18 10:57:43 UTC (rev 156)
@@ -1,6 +1,7 @@
package prc.bubulina.forum.dataclasses;
import java.sql.Date;
+import java.sql.Time;
public class Post {
public int post_id;
@@ -9,17 +10,20 @@
public int topic_id;
public int user_id;
public Date date;
+ public Time time;
- public Post(int post_id, String subject, String text, int topic_id, int user_id, Date date) {
+ public Post(int post_id, String subject, String text, int topic_id, int user_id, Date date, Time time) {
this.post_id = post_id;
this.subject = subject;
this.text = text;
this.topic_id = topic_id;
this.user_id = user_id;
this.date = date;
+ this.time = time;
}
public String toString() {
- return "ID: " + post_id + " Subject: " + subject + " Text: " + text + " TopicID: " + topic_id + " UserID: " + user_id + " Date: " + date;
+ return "ID: " + post_id + " Subject: " + subject + " Text: " + text + " TopicID: " + topic_id +
+ " UserID: " + user_id + " Date: " + date + " Time: " + time;
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-18 20:52:35
|
Revision: 161
http://cruce.svn.sourceforge.net/cruce/?rev=161&view=rev
Author: alinposho
Date: 2010-05-18 20:52:29 +0000 (Tue, 18 May 2010)
Log Message:
-----------
In momentul de fata aplicatia functioneaza 80%. Merge sa adaugi: thread-uri, post-uri, topic-uri, etc. Ce nu am incercat este daca mai functioneaaza si dupa modificarile facute de Horia astazi la structura bazei de date. Mai incercati si voi.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/Thread.jsp
JSP/trunk/Forum/WebContent/Topic.jsp
JSP/trunk/Forum/WebContent/commitRegister.jsp
JSP/trunk/Forum/WebContent/index.jsp
JSP/trunk/Forum/WebContent/pageStyle.css
JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java
Added Paths:
-----------
JSP/trunk/Forum/WebContent/logout.jsp
Modified: JSP/trunk/Forum/WebContent/Thread.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-18 19:40:50 UTC (rev 160)
+++ JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-18 20:52:29 UTC (rev 161)
@@ -17,8 +17,13 @@
<link rel="stylesheet" href="pageStyle.css" type="text/css">
<%
- String sID = request.getParameter("id");
- int id = Integer.parseInt(sID);
+
+ String stringID = request.getParameter("id");
+ if(stringID == null)
+ {
+ stringID = (String)session.getAttribute("currentThreadID");
+ }
+ int id = Integer.parseInt(stringID);
ForumThread thread = Singleton.getInstance().getThreadDAO().get(id);
session.setAttribute("currentThreadID", Integer.toString(thread.thread_id));
%>
@@ -36,7 +41,7 @@
%>
<!-- The form for adding a new Thread -->
<div id="leftContent" align="right">
- <FORM NAME="AddTopic" action="index.jsp" method="get">
+ <FORM NAME="AddTopic" action="Thread.jsp" method="get">
Topic name: <INPUT TYPE="TEXT" NAME="TopicName" value="">
<INPUT TYPE="submit" VALUE="Add Topic">
</FORM>
@@ -46,6 +51,16 @@
Hello <%out.print(user); %>!
Welcome to our forum.
</font>
+ <br>
+ <br>
+ <br>
+ <form name="logoutForm" action="logout.jsp" method="get">
+ <input type="submit" name="logout" value="logout" >
+ </form>
+ <%
+ //Setting the page to return to
+ session.setAttribute("pageToReturnTo", "Thread.jsp");
+ %>
</div>
<%
}
@@ -80,6 +95,14 @@
<th>Post count</th>
</tr>
<%
+ TopicDAO topicDAO = Singleton.getInstance().getTopicDAO();
+
+ //Checking for a topic that was added in the previous page
+ String topicName = request.getParameter("TopicName");
+ if(topicName != null && !topicName.equals(""))
+ {
+ topicDAO.add(topicName, thread);
+ }
List<Topic> topics = Singleton.getInstance().getThreadDAO().getTopics(id);
for(Topic t:topics) {
%>
Modified: JSP/trunk/Forum/WebContent/Topic.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Topic.jsp 2010-05-18 19:40:50 UTC (rev 160)
+++ JSP/trunk/Forum/WebContent/Topic.jsp 2010-05-18 20:52:29 UTC (rev 161)
@@ -10,22 +10,100 @@
<%@page import="prc.bubulina.forum.dataclasses.User"%>
<%@page import="java.util.*" %>
-<html>
+
+<%@page import="prc.bubulina.forum.businessLogic.Singleton"%>
+<%@page import="prc.bubulina.forum.data_access.PostDAO"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<%
- String sID = request.getParameter("id");
- int id = Integer.parseInt(sID);
- TopicDAO topicDAO = ForumDAOFactory.getTopicDAO();
+
+<!-- Linking css -->
+<link rel="stylesheet" href="pageStyle.css" type="text/css">
+
+<%
+ String stringID = request.getParameter("id");
+ if(stringID == null)
+ {
+ stringID = (String)session.getAttribute("currentThreadID");
+ }
+ TopicDAO topicDAO = Singleton.getInstance().getTopicDAO();
+ int id = Integer.parseInt(stringID);
Topic topic = topicDAO.get(id);
+ session.setAttribute("currentTopicID", Integer.toString(topic.topic_id));
%>
<title>Forum Bubulina: Topic - <% out.println(topic.subject); %></title>
</head>
<body>
+
+
+<!-- The so called header of the forum where you can login/register and add posts if
+you are logged in of course -->
+<%
+ //This form is to be dispayed only if the user is logged in
+ String user = (String)session.getAttribute("user");
+ if(user != null && !user.equalsIgnoreCase("null"))
+ {//If the user has logged in
+ %>
+ <!-- The form for adding a new Thread -->
+ <div id="leftContent" align="right">
+ <FORM NAME="AddPost" action="Topic.jsp" method="get">
+ Post text: <INPUT TYPE="TEXT" NAME="PostText" value="">
+ <INPUT TYPE="submit" VALUE="Add Post">
+ </FORM>
+ </div>
+ <div id="#rigthContent" align="right" >
+ <font size="4px">
+ Hello <%out.print(user); %>!
+ Welcome to our forum.
+ </font>
+ <br>
+ <br>
+ <br>
+ <form name="logoutForm" action="logout.jsp" method="get">
+ <input type="submit" name="logout" value="logout" >
+ </form>
+ <%
+ //Setting the page to return to
+ session.setAttribute("pageToReturnTo", "Topic.jsp");
+ %>
+ </div>
+ <%
+ }
+ else
+ {
+ %>
+
+ <div id="#rigthContent" align="right" >
+ <form name="Login" action="login.jsp" method="post">
+ User name: <input type="text" name="username"><br>
+ Password: <input type="password" name="password"><br>
+ <input type="submit" value="login">
+ </form>
+ <%
+ //Setting the page to return to
+ session.setAttribute("pageToReturnTo", "Topic.jsp");
+ %>
+ <form action="register.jsp" action=post>
+ <input type="submit" value="register">
+ </form>
+ </div>
+<% }
+%>
+
+
+
+
<div>
-<table border="1">
- <caption align="top">The posts this topic are:</caption>
+<table align = center>
+ <caption align="top">The posts on the topic: <%=topic.subject%> are:</caption>
<%
+ PostDAO postDAO = Singleton.getInstance().getPostDAO();
+ //Checking for a topic that was added in the previous page
+ String postText = request.getParameter("PostText");
+ if(postText != null && !postText.equals(""))
+ {
+ User u = Singleton.getInstance().getUserDAO().get(user);
+ postDAO.add(topic.subject, postText, topic.topic_id, u.user_id);
+ }
List<Post> posts = topicDAO.getPosts(id);
UserDAO userDAO = ForumDAOFactory.getUserDAO();
for(Post p:posts) {
@@ -36,12 +114,12 @@
</tr>
<tr>
<%
- User user = userDAO.get(p.user_id);
+ User userPost = userDAO.get(p.user_id);
%>
<td>
- Name: <% out.println(user.name); %> <br/>
- Post count: <% out.println(user.post_count); %> <br/>
- Joined: <% out.println(user.joined_date.toLocaleString()); %> <br/>
+ Name: <% out.println(userPost.name); %> <br/>
+ Post count: <% out.println(userPost.post_count); %> <br/>
+ Joined: <% out.println(userPost.joined_date.toLocaleString()); %> <br/>
</td>
<td>
<%
Modified: JSP/trunk/Forum/WebContent/commitRegister.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 19:40:50 UTC (rev 160)
+++ JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 20:52:29 UTC (rev 161)
@@ -77,8 +77,8 @@
<p>
Congratulations <%out.print(userName);%>. You have been successfully registered.
</p>
- <form action="index.jsp" method="post">
- <input type="submit" value="Back to main">
+ <form action="<%out.print((String)session.getAttribute("pageToReturnTo"));%>" method="post">
+ <input type="submit" value="Back to <%=(String)session.getAttribute("pageToReturnTo") %>">
</form>
<%
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 19:40:50 UTC (rev 160)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 20:52:29 UTC (rev 161)
@@ -34,8 +34,17 @@
<div id="#rigthContent" align="right" >
<font size="4px">
Hello <%out.print(user); %>!
- Welcome to our forum.
+ Welcome to our forum.
</font>
+ <br>
+ <br>
+ <form name="logoutForm" action="logout.jsp" method="get">
+ <input type="submit" name="logout" value="logout" >
+ </form>
+ <%
+ //Setting the page to return to
+ session.setAttribute("pageToReturnTo", "index.jsp");
+ %>
</div>
<%
}
Added: JSP/trunk/Forum/WebContent/logout.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/logout.jsp (rev 0)
+++ JSP/trunk/Forum/WebContent/logout.jsp 2010-05-18 20:52:29 UTC (rev 161)
@@ -0,0 +1,15 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+<body>
+ <%
+ session.removeAttribute("user");
+ %>
+ <jsp:forward page="<%=(String)session.getAttribute("pageToReturnTo")%>"></jsp:forward>
+</body>
+</html>
\ No newline at end of file
Modified: JSP/trunk/Forum/WebContent/pageStyle.css
===================================================================
--- JSP/trunk/Forum/WebContent/pageStyle.css 2010-05-18 19:40:50 UTC (rev 160)
+++ JSP/trunk/Forum/WebContent/pageStyle.css 2010-05-18 20:52:29 UTC (rev 161)
@@ -3,7 +3,7 @@
border: 10px solid blue;
border-collapse: collapse;
align: center;
- width: 80%
+ width: 80%;
}
th{
@@ -31,6 +31,7 @@
voice-family: "\"}\"";
voice-family:inherit;
width: 270px;
+ heigth: 100px;
}
html>body #leftContent {
width: 270px; /* ie5win fudge ends */
@@ -42,6 +43,7 @@
voice-family: "\"}\"";
voice-family:inherit;
width: 270px;
+ heigth: 100px;
}
html>body #rigthContent {
width: 270px; /* ie5win fudge ends */
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java 2010-05-18 19:40:50 UTC (rev 160)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/businessLogic/Singleton.java 2010-05-18 20:52:29 UTC (rev 161)
@@ -2,18 +2,24 @@
import prc.bubulina.forum.data_access.ForumDAOFactory;
import prc.bubulina.forum.data_access.ForumThreadDAO;
+import prc.bubulina.forum.data_access.PostDAO;
+import prc.bubulina.forum.data_access.TopicDAO;
import prc.bubulina.forum.data_access.UserDAO;
public class Singleton
{
private ForumThreadDAO threadDAO;
+ private TopicDAO topicDAO;
private UserDAO users;
+ private PostDAO postDAO;
private static Singleton instance = null;
private Singleton()
{
threadDAO = ForumDAOFactory.getThreadDAO();
users = ForumDAOFactory.getUserDAO();
+ topicDAO = ForumDAOFactory.getTopicDAO();
+ postDAO = ForumDAOFactory.getPostDAO();
}
public static Singleton getInstance()
@@ -34,5 +40,16 @@
public UserDAO getUserDAO()
{
return users;
+ }
+
+ public TopicDAO getTopicDAO()
+ {
+ return topicDAO;
+ }
+
+ public PostDAO getPostDAO()
+ {
+ return postDAO;
}
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-25 09:41:07
|
Revision: 162
http://cruce.svn.sourceforge.net/cruce/?rev=162&view=rev
Author: alinposho
Date: 2010-05-25 09:40:59 +0000 (Tue, 25 May 2010)
Log Message:
-----------
Am modificat codul din pagina Topic.jsp. Din cate am testat eu, nu mai apar probleme la adaugarea post-urilor. Va rog sa testati si voi.
Nu sunt foarte sigur dar acum functioneaza cum ar trebui si butonul de back al browser-ului.
Acum adaug si un buton de Home.
Modified Paths:
--------------
JSP/trunk/Forum/.classpath
JSP/trunk/Forum/WebContent/Topic.jsp
Modified: JSP/trunk/Forum/.classpath
===================================================================
--- JSP/trunk/Forum/.classpath 2010-05-18 20:52:29 UTC (rev 161)
+++ JSP/trunk/Forum/.classpath 2010-05-25 09:40:59 UTC (rev 162)
@@ -1,13 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-sun-1.6.0.20">
- <attributes>
- <attribute name="owner.project.facets" value="jst.java"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
- <classpathentry kind="lib" path="/home/caius/apache-tomcat-6.0.26/lib/servlet-api.jar"/>
- <classpathentry kind="output" path="build/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Modified: JSP/trunk/Forum/WebContent/Topic.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Topic.jsp 2010-05-18 20:52:29 UTC (rev 161)
+++ JSP/trunk/Forum/WebContent/Topic.jsp 2010-05-25 09:40:59 UTC (rev 162)
@@ -23,7 +23,7 @@
String stringID = request.getParameter("id");
if(stringID == null)
{
- stringID = (String)session.getAttribute("currentThreadID");
+ stringID = (String)session.getAttribute("currentTopicID");
}
TopicDAO topicDAO = Singleton.getInstance().getTopicDAO();
int id = Integer.parseInt(stringID);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|