cruce-commit Mailing List for Cruce
Status: Beta
Brought to you by:
caiusb
You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
(68) |
Apr
(51) |
May
(31) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <ali...@us...> - 2010-05-26 09:37:33
|
Revision: 166
http://cruce.svn.sourceforge.net/cruce/?rev=166&view=rev
Author: alinposho
Date: 2010-05-26 09:37:26 +0000 (Wed, 26 May 2010)
Log Message:
-----------
Am pus si documentatia pe SVN.
Added Paths:
-----------
JSP/trunk/Forum/forumDoc.pdf
Added: JSP/trunk/Forum/forumDoc.pdf
===================================================================
(Binary files differ)
Property changes on: JSP/trunk/Forum/forumDoc.pdf
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ca...@us...> - 2010-05-25 14:04:54
|
Revision: 165
http://cruce.svn.sourceforge.net/cruce/?rev=165&view=rev
Author: caiusb
Date: 2010-05-25 14:04:46 +0000 (Tue, 25 May 2010)
Log Message:
-----------
Added the ant script
Added Paths:
-----------
JSP/trunk/Forum/build.xml
Added: JSP/trunk/Forum/build.xml
===================================================================
--- JSP/trunk/Forum/build.xml (rev 0)
+++ JSP/trunk/Forum/build.xml 2010-05-25 14:04:46 UTC (rev 165)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- WARNING: Eclipse auto-generated file.
+ Any modifications will be overwritten.
+ To include a user specific buildfile here, simply create one in the same
+ directory with the processing instruction <?eclipse.ant.import?>
+ as the first entry and export the buildfile again. -->
+<project basedir="." default="build" name="Forum">
+ <property environment="env"/>
+ <property name="debuglevel" value="source,lines,vars"/>
+ <property name="target" value="1.6"/>
+ <property name="source" value="1.6"/>
+ <path id="Web App Libraries.libraryclasspath">
+ <pathelement location="WebContent/WEB-INF/lib/mysql-connector-java-5.1.12-bin.jar"/>
+ </path>
+ <path id="EAR Libraries.libraryclasspath"/>
+ <path id="Forum.classpath">
+ <pathelement location="build/classes"/>
+ <path refid="Web App Libraries.libraryclasspath"/>
+ <path refid="EAR Libraries.libraryclasspath"/>
+ <pathelement location="../../../apache-tomcat-6.0.26/lib/servlet-api.jar"/>
+ </path>
+ <target name="init">
+ <mkdir dir="build/classes"/>
+ <copy includeemptydirs="false" todir="build/classes">
+ <fileset dir="src">
+ <exclude name="**/*.launch"/>
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+ <target name="clean">
+ <delete dir="build/classes"/>
+ </target>
+ <target depends="clean" name="cleanall"/>
+ <target depends="build-subprojects,build-project" name="build"/>
+ <target name="build-subprojects"/>
+ <target depends="init" name="build-project">
+ <echo message="${ant.project.name}: ${ant.file}"/>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="build/classes" source="${source}" target="${target}">
+ <src path="src"/>
+ <classpath refid="Forum.classpath"/>
+ </javac>
+ </target>
+ <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
+ <target name="Test">
+ <java classname="prc.bubulina.forum.test.Test" failonerror="true" fork="yes">
+ <classpath refid="Forum.classpath"/>
+ </java>
+ </target>
+
+ <target name="deploy" depends="build">
+ <war destfile="Forum.war" webxml="WebContent/WEB-INF/web.xml">
+ <fileset dir="WebContent"/>
+ <classes dir="build/classes"/>
+ </war>
+ </target>
+</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-25 10:06:17
|
Revision: 164
http://cruce.svn.sourceforge.net/cruce/?rev=164&view=rev
Author: alinposho
Date: 2010-05-25 10:06:10 +0000 (Tue, 25 May 2010)
Log Message:
-----------
Mici modificari la alinierea butoanelor.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/commitRegister.jsp
JSP/trunk/Forum/WebContent/login.jsp
Modified: JSP/trunk/Forum/WebContent/commitRegister.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-25 10:02:49 UTC (rev 163)
+++ JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-25 10:06:10 UTC (rev 164)
@@ -74,12 +74,14 @@
else
{
%>
- <p>
+ <p align="center">
Congratulations <%out.print(userName);%>. You have been successfully registered.
</p>
+ <div align="center">
<form action="<%out.print((String)session.getAttribute("pageToReturnTo"));%>" method="post">
<input type="submit" value="Back to <%=(String)session.getAttribute("pageToReturnTo") %>">
- </form>
+ </form>
+ </div>
<%
}
Modified: JSP/trunk/Forum/WebContent/login.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/login.jsp 2010-05-25 10:02:49 UTC (rev 163)
+++ JSP/trunk/Forum/WebContent/login.jsp 2010-05-25 10:06:10 UTC (rev 164)
@@ -43,14 +43,15 @@
if(problem != null)
{
%>
- <p align="center">
+ <div align="center">
There is the following problem: <%out.println(problem); %>.<br>
Please try signing in again.
<form action="<% out.print((String)session.getAttribute("pageToReturnTo")); %>"
method="post" >
<input align="top" type="submit"
value="Back to <% out.print((String)session.getAttribute("pageToReturnTo"));%>">
- </form>
+ </form>
+ </div>
<%
}
else
@@ -59,13 +60,14 @@
//Saving the new logged user in the cookies
session.setAttribute("user", userName);
%>
- <p align="center">
+ <div align="center">
Congratulations <%out.print(userName);%>. You have been successfully logged in.
<form action="<% out.print((String)session.getAttribute("pageToReturnTo")); %>"
method="post" >
<input align="top" type="submit"
value="Back to <% out.print((String)session.getAttribute("pageToReturnTo"));%>">
- </form>
+ </form>
+ </div>
<%
}
%>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-25 10:02:56
|
Revision: 163
http://cruce.svn.sourceforge.net/cruce/?rev=163&view=rev
Author: alinposho
Date: 2010-05-25 10:02:49 +0000 (Tue, 25 May 2010)
Log Message:
-----------
Am adaugat si un buton de Home. Sper sa fie totul OK.
Va rog jucati-va si voi cu apicatia.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/Thread.jsp
JSP/trunk/Forum/WebContent/Topic.jsp
JSP/trunk/Forum/WebContent/index.jsp
Modified: JSP/trunk/Forum/WebContent/Thread.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-25 09:40:59 UTC (rev 162)
+++ JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-25 10:02:49 UTC (rev 163)
@@ -29,8 +29,25 @@
%>
<title>Forum Bubulina: Thread - <% out.println(thread.name); %></title>
</head>
+
+
+
+
<body>
+
+
+<!-- The home button -->
+<br>
+<div align="center">
+<form name="Home" action="index.jsp" method="post" >
+ <input type="submit" value="home" >
+</form>
+</div>
+
+
+
+
<!-- The so called header of the forum where you can login/register and add topics if
you are logged in of course -->
<%
@@ -85,6 +102,11 @@
<% }
%>
+
+
+
+
+
<!-- The actual table with topics -->
<div>
Modified: JSP/trunk/Forum/WebContent/Topic.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Topic.jsp 2010-05-25 09:40:59 UTC (rev 162)
+++ JSP/trunk/Forum/WebContent/Topic.jsp 2010-05-25 10:02:49 UTC (rev 163)
@@ -35,6 +35,16 @@
<body>
+<!-- The home button -->
+<br>
+<div align="center">
+<form name="Home" action="index.jsp" method="post" >
+ <input type="submit" value="home" >
+</form>
+</div>
+
+
+
<!-- The so called header of the forum where you can login/register and add posts if
you are logged in of course -->
<%
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-25 09:40:59 UTC (rev 162)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-25 10:02:49 UTC (rev 163)
@@ -16,6 +16,17 @@
</head>
<body>
+
+<!-- The home button -->
+<br>
+<div align="center">
+<form name="Home" action="index.jsp" method="post" >
+ <input type="submit" value="home" >
+</form>
+</div>
+
+
+
<!-- The so called header of the forum where you can login/register and add threads if
you are logged in of course -->
<%
@@ -44,7 +55,7 @@
<%
//Setting the page to return to
session.setAttribute("pageToReturnTo", "index.jsp");
- %>
+ %>
</div>
<%
}
@@ -69,6 +80,8 @@
<% }
%>
+
+
<!-- The actual table with threads -->
<br>
<div>
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.
|
|
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-18 19:40:56
|
Revision: 160
http://cruce.svn.sourceforge.net/cruce/?rev=160&view=rev
Author: alinposho
Date: 2010-05-18 19:40:50 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/login.jsp
Modified: JSP/trunk/Forum/WebContent/login.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/login.jsp 2010-05-18 16:15:23 UTC (rev 159)
+++ JSP/trunk/Forum/WebContent/login.jsp 2010-05-18 19:40:50 UTC (rev 160)
@@ -41,15 +41,17 @@
}
}
if(problem != null)
- {
+ {
%>
<p align="center">
There is the following problem: <%out.println(problem); %>.<br>
Please try signing in again.
- <form action="index.jsp" method="post" >
- <input align="top" type="submit" value="Back to main">
+ <form action="<% out.print((String)session.getAttribute("pageToReturnTo")); %>"
+ method="post" >
+ <input align="top" type="submit"
+ value="Back to <% out.print((String)session.getAttribute("pageToReturnTo"));%>">
</form>
- <%
+ <%
}
else
{
@@ -59,8 +61,10 @@
%>
<p align="center">
Congratulations <%out.print(userName);%>. You have been successfully logged in.
- <form action="index.jsp" method="post" >
- <input align="top" type="submit" value="Back to main">
+ <form action="<% out.print((String)session.getAttribute("pageToReturnTo")); %>"
+ method="post" >
+ <input align="top" type="submit"
+ value="Back to <% out.print((String)session.getAttribute("pageToReturnTo"));%>">
</form>
<%
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-18 16:15:29
|
Revision: 159
http://cruce.svn.sourceforge.net/cruce/?rev=159&view=rev
Author: alinposho
Date: 2010-05-18 16:15:23 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Something s very wrong with this Web designing. I can't take it any more!
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/Thread.jsp
JSP/trunk/Forum/WebContent/index.jsp
Modified: JSP/trunk/Forum/WebContent/Thread.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-18 15:14:48 UTC (rev 158)
+++ JSP/trunk/Forum/WebContent/Thread.jsp 2010-05-18 16:15:23 UTC (rev 159)
@@ -12,17 +12,69 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+
+<!-- Linking css -->
+<link rel="stylesheet" href="pageStyle.css" type="text/css">
+
<%
String sID = request.getParameter("id");
int id = Integer.parseInt(sID);
- ForumThread thread = Singleton.getInstance().getThreadDAO().get(id);;
+ ForumThread thread = Singleton.getInstance().getThreadDAO().get(id);
+ session.setAttribute("currentThreadID", Integer.toString(thread.thread_id));
%>
<title>Forum Bubulina: Thread - <% out.println(thread.name); %></title>
</head>
<body>
+
+<!-- The so called header of the forum where you can login/register and add topics 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="AddTopic" action="index.jsp" method="get">
+ Topic name: <INPUT TYPE="TEXT" NAME="TopicName" value="">
+ <INPUT TYPE="submit" VALUE="Add Topic">
+ </FORM>
+ </div>
+ <div id="#rigthContent" align="right" >
+ <font size="4px">
+ Hello <%out.print(user); %>!
+ Welcome to our forum.
+ </font>
+ </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", "Thread.jsp");
+ %>
+ <form action="register.jsp" action=post>
+ <input type="submit" value="register">
+ </form>
+ </div>
+<% }
+%>
+
+<!-- The actual table with topics -->
+
<div>
-<table>
- <caption align="top">Topics in this thread are:</caption>
+<table align = center>
+ <caption align="top">Topics in thread <%out.print(thread.name); %> are:</caption>
<tr>
<th>Topic name</th>
<th>Post count</th>
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 15:14:48 UTC (rev 158)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 16:15:23 UTC (rev 159)
@@ -11,13 +11,13 @@
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Team Bubulina's Forum</title>
-
<!-- Linking css -->
<link rel="stylesheet" href="pageStyle.css" type="text/css">
</head>
<body>
-
+<!-- The so called header of the forum where you can login/register and add threads 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");
@@ -49,6 +49,10 @@
Password: <input type="password" name="password"><br>
<input type="submit" value="login">
</form>
+ <%
+ //Setting the page to return to
+ session.setAttribute("pageToReturnTo", "index.jsp");
+ %>
<form action="register.jsp" action=post>
<input type="submit" value="register">
</form>
@@ -57,7 +61,7 @@
%>
<!-- The actual table with threads -->
-
+<br>
<div>
<table align = center>
<caption align="top">The threads running on this forum are:<br></caption>
@@ -78,10 +82,10 @@
for (ForumThread thread : threads.getAllThreads()) {
%>
<tr>
- <td>
+ <td>
<a href=Thread.jsp?id=<%= thread.thread_id %>>
- <%
- out.print(thread.name);
+ <%
+ out.print(thread.name);
%>
</a>
</td>
@@ -97,12 +101,6 @@
</table>
</div>
-<!-- Forwarding user name -->
-<form name="dummy">
-<input type="hidden" name="user"
- value="<%request.getParameter("user"); %>"
- >
-</form>
<p>
</p>
</body>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ali...@us...> - 2010-05-18 15:14:54
|
Revision: 158
http://cruce.svn.sourceforge.net/cruce/?rev=158&view=rev
Author: alinposho
Date: 2010-05-18 15:14:48 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Am pus css-ul din login intr-o pagina separata si l-am legat ca si css extern urmand sa fac acelasi lucru si pentru paginile: Thread si Topic
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/commitRegister.jsp
JSP/trunk/Forum/WebContent/index.jsp
JSP/trunk/Forum/WebContent/login.jsp
Added Paths:
-----------
JSP/trunk/Forum/WebContent/pageStyle.css
Modified: JSP/trunk/Forum/WebContent/commitRegister.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 14:44:10 UTC (rev 157)
+++ JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 15:14:48 UTC (rev 158)
@@ -67,9 +67,7 @@
{
//saving problem string as a session variable
session.setAttribute("problem", problem);
- %>
- <!-- Forwarding problem -->
-
+ %>
<jsp:forward page="register.jsp"></jsp:forward>
<%
}
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 14:44:10 UTC (rev 157)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 15:14:48 UTC (rev 158)
@@ -10,77 +10,33 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Team Bubulina's Forum</title>
-<style type="text/css">
-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;
-}
+<!-- Linking css -->
+<link rel="stylesheet" href="pageStyle.css" type="text/css">
-a:link {
- 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");
+ 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">
- Thread name: <INPUT TYPE="TEXT" NAME="ThreadName" value="">
- <FORM NAME="AddThread" action="index.jsp" method="get">
- <INPUT TYPE="submit" VALUE="Add 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>
+ <div id="#rigthContent" align="right" >
+ <font size="4px">
+ Hello <%out.print(user); %>!
+ Welcome to our forum.
+ </font>
+ </div>
<%
}
else
@@ -91,20 +47,7 @@
<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">
- <%
- //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>
- <%
- }
- %>
+ <input type="submit" value="login">
</form>
<form action="register.jsp" action=post>
<input type="submit" value="register">
Modified: JSP/trunk/Forum/WebContent/login.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/login.jsp 2010-05-18 14:44:10 UTC (rev 157)
+++ JSP/trunk/Forum/WebContent/login.jsp 2010-05-18 15:14:48 UTC (rev 158)
@@ -7,9 +7,10 @@
<%@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>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <title>login</title>
</head>
<body>
<%
@@ -42,30 +43,25 @@
if(problem != null)
{
%>
- <!-- Forwarding problem -->
- <form name="dummy2">
- <input type="hidden" name="problem" value="<%out.print(problem);%>">
- </form>
+ <p align="center">
+ There is the following problem: <%out.println(problem); %>.<br>
+ Please try signing in again.
+ <form action="index.jsp" method="post" >
+ <input align="top" type="submit" value="Back to main">
+ </form>
<%
- String redirectURL = "index.jsp";
- response.sendRedirect(redirectURL);
}
else
{
- //All OK
- %>
- <!-- Forwarding user name -->
- <form name="dummy">
- <input type="hidden" name="user"
- value="<%out.print(userName);%>"
- >
- </form>
- <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>
+ //All OK
+ //Saving the new logged user in the cookies
+ session.setAttribute("user", userName);
+ %>
+ <p align="center">
+ Congratulations <%out.print(userName);%>. You have been successfully logged in.
+ <form action="index.jsp" method="post" >
+ <input align="top" type="submit" value="Back to main">
+ </form>
<%
}
%>
Added: JSP/trunk/Forum/WebContent/pageStyle.css
===================================================================
--- JSP/trunk/Forum/WebContent/pageStyle.css (rev 0)
+++ JSP/trunk/Forum/WebContent/pageStyle.css 2010-05-18 15:14:48 UTC (rev 158)
@@ -0,0 +1,48 @@
+@CHARSET "ISO-8859-1";
+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;
+}
+
+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 */
+ }
\ 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 14:44:16
|
Revision: 157
http://cruce.svn.sourceforge.net/cruce/?rev=157&view=rev
Author: alinposho
Date: 2010-05-18 14:44:10 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Pagina de register merger super. Chiar si informatiile sunt afisate corect!
Caius scoate fiserul: "classpath" de pe svn te rog.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/commitRegister.jsp
JSP/trunk/Forum/WebContent/register.jsp
Modified: JSP/trunk/Forum/WebContent/commitRegister.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 10:57:43 UTC (rev 156)
+++ JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 14:44:10 UTC (rev 157)
@@ -6,7 +6,7 @@
<%@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>
+<title>Register</title>
</head>
<body>
@@ -47,36 +47,32 @@
{
problem = "null or empty email!";
}
+ else
+ {
+ if(userDAO.add(userName, password, email) == null)
+ {
+ %>
+ <script>
+ alert("Problem registering user! Please try again");
+ </script>
+ <%
+ problem = "Problem registering user! Please try again";
+ }
+ }
}
}
}
}
if(problem != null)
{
+ //saving problem string as a session variable
+ session.setAttribute("problem", problem);
%>
<!-- Forwarding problem -->
- <form name="dummy2">
- <input type="hidden" name="problem" value="<%out.print(problem);%>"
- >
- <p>
- there was the following problem: <%out.print(problem);%>.
- </p>
- </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
{
%>
@@ -84,15 +80,8 @@
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>
-
+ <input type="submit" value="Back to main">
+ </form>
<%
}
Modified: JSP/trunk/Forum/WebContent/register.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/register.jsp 2010-05-18 10:57:43 UTC (rev 156)
+++ JSP/trunk/Forum/WebContent/register.jsp 2010-05-18 14:44:10 UTC (rev 157)
@@ -6,31 +6,25 @@
<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");
+ String problem = (String)session.getAttribute("problem");
if(problem != null && (problem.isEmpty() == false)
&& (problem.equals("null")) == false)
{
%>
- <font color="red" size="14">
+ <p align="center">
+ <font color="red" size="3px">
There is the following problem: <%out.println(problem); %>
+ <br>
+ Please re-enter fields.
</font>
+ </p>
<%
}
%>
- <form name="register" action="commitRegister.jsp" method="post">
+ <form name="register" action="commitRegister.jsp" method="get">
<table align="center" width="80%">
<tr>
<td align="right">
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: <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: <ali...@us...> - 2010-05-18 10:02:41
|
Revision: 154
http://cruce.svn.sourceforge.net/cruce/?rev=154&view=rev
Author: alinposho
Date: 2010-05-18 10:02:35 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Acum merge sa dai register, dar daca introuduci campuri gresite sau un unsername care mai exista deja nu te anunta corect.
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/index.jsp
JSP/trunk/Forum/WebContent/login.jsp
JSP/trunk/Forum/WebContent/register.jsp
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 08:46:28 UTC (rev 153)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 10:02:35 UTC (rev 154)
@@ -70,9 +70,9 @@
{
%>
<!-- The form for adding a new Thread -->
- <div id="leftContent" align="right">
+ <div id="leftContent" align="right">
+ Thread name: <INPUT TYPE="TEXT" NAME="ThreadName" value="">
<FORM NAME="AddThread" action="index.jsp" method="get">
- Thread name: <INPUT TYPE="TEXT" NAME="ThreadName" value="">
<INPUT TYPE="submit" VALUE="Add Thread">
</FORM>
</div>
@@ -87,10 +87,10 @@
{
%>
- <div id="#rigthContent" align="right" >
+ <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>
- <form name="LoginForm" action="login.jsp" method="post">
<input type="submit" value="login">
<%
//Handling posible login problems
Modified: JSP/trunk/Forum/WebContent/login.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/login.jsp 2010-05-18 08:46:28 UTC (rev 153)
+++ JSP/trunk/Forum/WebContent/login.jsp 2010-05-18 10:02:35 UTC (rev 154)
@@ -44,29 +44,28 @@
%>
<!-- Forwarding problem -->
<form name="dummy2">
- <input type="hidden" name="problem" value="<%out.print(problem);%>"
- >
+ <input type="hidden" name="problem" value="<%out.print(problem);%>">
</form>
- <jsp:forward page="index.jsp"></jsp:forward>
<%
+ String redirectURL = "index.jsp";
+ response.sendRedirect(redirectURL);
}
else
{
//All OK
%>
+ <!-- Forwarding user name -->
+ <form name="dummy">
+ <input type="hidden" name="user"
+ value="<%out.print(userName);%>"
+ >
+ </form>
<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>
-
+ </form>
<%
}
%>
Modified: JSP/trunk/Forum/WebContent/register.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/register.jsp 2010-05-18 08:46:28 UTC (rev 153)
+++ JSP/trunk/Forum/WebContent/register.jsp 2010-05-18 10:02:35 UTC (rev 154)
@@ -30,7 +30,7 @@
<%
}
%>
-
+ <form name="register" action="commitRegister.jsp" method="post">
<table align="center" width="80%">
<tr>
<td align="right">
@@ -66,13 +66,11 @@
</tr>
<tr>
<td></td>
- <td>
- <form name="register" action="commitRegister.jsp" method="post">
- <input type="submit" value="Submit" name="submit">
- </form>
+ <td>
+ <input type="submit" value="Submit" name="submit">
</td>
</tr>
</table>
-
+ </form>
</body>
</html>
\ 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 08:46:34
|
Revision: 153
http://cruce.svn.sourceforge.net/cruce/?rev=153&view=rev
Author: alinposho
Date: 2010-05-18 08:46:28 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/commitRegister.jsp
JSP/trunk/Forum/WebContent/index.jsp
JSP/trunk/Forum/WebContent/register.jsp
Modified: JSP/trunk/Forum/WebContent/commitRegister.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 08:38:40 UTC (rev 152)
+++ JSP/trunk/Forum/WebContent/commitRegister.jsp 2010-05-18 08:46:28 UTC (rev 153)
@@ -58,6 +58,9 @@
<form name="dummy2">
<input type="hidden" name="problem" value="<%out.print(problem);%>"
>
+ <p>
+ there was the following problem: <%out.print(problem);%>.
+ </p>
</form>
<jsp:forward page="register.jsp"></jsp:forward>
<%
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 08:38:40 UTC (rev 152)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-18 08:46:28 UTC (rev 153)
@@ -87,10 +87,10 @@
{
%>
- <div id="#rigthContent" align="right" >
- <form name="LoginForm" action="login.jsp" method="post">
+ <div id="#rigthContent" align="right" >
User name: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
+ <form name="LoginForm" action="login.jsp" method="post">
<input type="submit" value="login">
<%
//Handling posible login problems
Modified: JSP/trunk/Forum/WebContent/register.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/register.jsp 2010-05-18 08:38:40 UTC (rev 152)
+++ JSP/trunk/Forum/WebContent/register.jsp 2010-05-18 08:46:28 UTC (rev 153)
@@ -30,7 +30,7 @@
<%
}
%>
- <form name="register" action="commitRegister.jsp" method="post">
+
<table align="center" width="80%">
<tr>
<td align="right">
@@ -67,10 +67,12 @@
<tr>
<td></td>
<td>
+ <form name="register" action="commitRegister.jsp" method="post">
<input type="submit" value="Submit" name="submit">
+ </form>
</td>
</tr>
</table>
- </form>
+
</body>
</html>
\ 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 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: <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: <hor...@us...> - 2010-05-17 16:41:45
|
Revision: 150
http://cruce.svn.sourceforge.net/cruce/?rev=150&view=rev
Author: horiaradu
Date: 2010-05-17 16:41:38 +0000 (Mon, 17 May 2010)
Log Message:
-----------
Am adaugat in BD: post_count la tabela Topics.
Modified Paths:
--------------
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.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/dataclasses/Topic.java
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 16:29:08 UTC (rev 149)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java 2010-05-17 16:41:38 UTC (rev 150)
@@ -92,7 +92,7 @@
List<Topic> result = new LinkedList<Topic>();
while (rs.next()) {
- Topic t = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"));
+ Topic t = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"), rs.getInt("post_count"));
result.add(t);
}
return result;
@@ -110,7 +110,7 @@
List<Topic> result = new LinkedList<Topic>();
while (rs.next()) {
- Topic t = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"));
+ Topic t = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"), rs.getInt("post_count"));
result.add(t);
}
return result;
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-17 16:29:08 UTC (rev 149)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/PostDAO.java 2010-05-17 16:41:38 UTC (rev 150)
@@ -39,6 +39,9 @@
queryString = "UPDATE users SET post_count=post_count+1 WHERE user_id=" + user_id + ";";
stmt.executeUpdate(queryString);
+ queryString = "UPDATE topics SET post_count=post_count+1 WHERE topic_id=" + topic_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 + "\";");
@@ -64,6 +67,7 @@
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 + ";");
+ stmt.executeUpdate("UPDATE topics SET post_count=post_count-1 WHERE topic_id=" + post.topic_id + ";");
con.close();
return true;
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-17 16:29:08 UTC (rev 149)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/TopicDAO.java 2010-05-17 16:41:38 UTC (rev 150)
@@ -18,7 +18,7 @@
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"));
+ Topic result = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"), rs.getInt("post_count"));
con.close();
@@ -47,7 +47,7 @@
" AND thread_id=\"" + thread.thread_id + "\";");
rs.first();
- Topic result = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"));
+ Topic result = new Topic(rs.getInt("topic_id"), rs.getString("subject"), rs.getInt("thread_id"), rs.getInt("post_count"));
con.close();
return result;
Modified: JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java
===================================================================
--- JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java 2010-05-17 16:29:08 UTC (rev 149)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/dataclasses/Topic.java 2010-05-17 16:41:38 UTC (rev 150)
@@ -4,14 +4,16 @@
public int topic_id;
public String subject;
public int thread_id;
+ public int post_count;
- public Topic(int topic_id, String subject, int thread_id) {
+ public Topic(int topic_id, String subject, int thread_id, int post_count) {
this.topic_id = topic_id;
this.subject = subject;
this.thread_id = thread_id;
+ this.post_count = post_count;
}
public String toString() {
- return "ID: " + topic_id + " Subject: " + subject + " ThreadID: " + thread_id;
+ return "ID: " + topic_id + " Subject: " + subject + " ThreadID: " + thread_id + " Nrposts: " + post_count;
}
}
\ 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 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 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-16 18:55:20
|
Revision: 147
http://cruce.svn.sourceforge.net/cruce/?rev=147&view=rev
Author: caiusb
Date: 2010-05-16 18:55:14 +0000 (Sun, 16 May 2010)
Log Message:
-----------
Tweaking the estetic part
Modified Paths:
--------------
JSP/trunk/Forum/WebContent/index.jsp
Modified: JSP/trunk/Forum/WebContent/index.jsp
===================================================================
--- JSP/trunk/Forum/WebContent/index.jsp 2010-05-16 17:54:25 UTC (rev 146)
+++ JSP/trunk/Forum/WebContent/index.jsp 2010-05-16 18:55:14 UTC (rev 147)
@@ -1,6 +1,5 @@
<%@ 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">
<%@page import="prc.bubulina.forum.data_access.ForumThreadDAO"%>
@@ -10,49 +9,53 @@
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Team Bubulina's Forum</title>
<style type="text/css">
-<!--
- table
- {
- border="10";
- bordercolor="blue";
- align="center";
- width="80%"
- }
+table,th,td {
+ border: 1px solid blue;
+ border-collapse: collapse;
+}
- a:link {color: green;
- background: red}
+a:link {
+ color: green;
+ background: red
+}
- h1 {font-weight: bold;
- text-align: center;}
--->
+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>
- <%}%>
+ <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>
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: <hor...@us...> - 2010-05-16 17:02:40
|
Revision: 145
http://cruce.svn.sourceforge.net/cruce/?rev=145&view=rev
Author: horiaradu
Date: 2010-05-16 17:02:34 +0000 (Sun, 16 May 2010)
Log Message:
-----------
am modif un pic scriptul ca sa creez baza de date
Modified Paths:
--------------
JSP/trunk/Forum/bd_script.sql
Modified: JSP/trunk/Forum/bd_script.sql
===================================================================
--- JSP/trunk/Forum/bd_script.sql 2010-05-16 16:12:53 UTC (rev 144)
+++ JSP/trunk/Forum/bd_script.sql 2010-05-16 17:02:34 UTC (rev 145)
@@ -1,3 +1,5 @@
+CREATE DATABASE forum;
+
use forum;
CREATE TABLE users (
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: <hor...@us...> - 2010-05-16 14:28:35
|
Revision: 143
http://cruce.svn.sourceforge.net/cruce/?rev=143&view=rev
Author: horiaradu
Date: 2010-05-16 14:28:29 +0000 (Sun, 16 May 2010)
Log Message:
-----------
am adaugat posibilitatea de a lua toate thread-urile
Modified Paths:
--------------
JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java
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-14 17:02:08 UTC (rev 142)
+++ JSP/trunk/Forum/src/prc/bubulina/forum/data_access/ForumThreadDAO.java 2010-05-16 14:28:29 UTC (rev 143)
@@ -82,4 +82,22 @@
}
return null;
}
+
+ public List<ForumThread> getAllThreads() {
+ try {
+ Connection con = ForumDAOFactory.createConnection();
+ Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM threads;");
+
+ List<ForumThread> result = new LinkedList<ForumThread>();
+ while (rs.next()) {
+ ForumThread t = new ForumThread(rs.getInt("thread_id"), rs.getString("name"), rs.getInt("topic_count"));
+ result.add(t);
+ }
+ return result;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
\ 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.
|