diff --git a/.classpath b/.classpath new file mode 100644 index 00000000..878bbb0c --- /dev/null +++ b/.classpath @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4521c121 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/nbproject/private/ +/nbbuild/ \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 00000000..25372d34 --- /dev/null +++ b/.project @@ -0,0 +1,36 @@ + + + WBD Project + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 00000000..3a28de0c --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f42de363 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 00000000..8ce60a57 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 00000000..b3f07fe4 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 00000000..3bd5d0a4 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 00000000..05bd71b6 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/build.xml b/build.xml new file mode 100644 index 00000000..24c940a7 --- /dev/null +++ b/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project tubes. + + + diff --git a/build/classes/LoginHandler.class b/build/classes/LoginHandler.class new file mode 100644 index 00000000..f4ac632f Binary files /dev/null and b/build/classes/LoginHandler.class differ diff --git a/build/classes/NewCommentServlet.class b/build/classes/NewCommentServlet.class new file mode 100644 index 00000000..0a714d4f Binary files /dev/null and b/build/classes/NewCommentServlet.class differ diff --git a/build/classes/NewPostServlet.class b/build/classes/NewPostServlet.class new file mode 100644 index 00000000..31c484a0 Binary files /dev/null and b/build/classes/NewPostServlet.class differ diff --git a/build/classes/SignupHandler.class b/build/classes/SignupHandler.class new file mode 100644 index 00000000..4773cb5d Binary files /dev/null and b/build/classes/SignupHandler.class differ diff --git a/build/classes/UpdatePost.class b/build/classes/UpdatePost.class new file mode 100644 index 00000000..52aacf7f Binary files /dev/null and b/build/classes/UpdatePost.class differ diff --git a/build/classes/UpdatePostServlet.class b/build/classes/UpdatePostServlet.class new file mode 100644 index 00000000..d63bd59d Binary files /dev/null and b/build/classes/UpdatePostServlet.class differ diff --git a/build/classes/com/test/Test.class b/build/classes/com/test/Test.class new file mode 100644 index 00000000..c5704839 Binary files /dev/null and b/build/classes/com/test/Test.class differ diff --git a/build/web/FileCounter.java b/build/web/FileCounter.java new file mode 100644 index 00000000..af4dfe5e --- /dev/null +++ b/build/web/FileCounter.java @@ -0,0 +1,73 @@ + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +/** + * Servlet implementation class FileCounter + */ +@WebServlet("/FileCounter") +public class FileCounter extends HttpServlet { + private static final long serialVersionUID = 1L; + int count; + private FileDao dao; + /** + * @see HttpServlet#HttpServlet() + */ + public FileCounter() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // Set a cookie for the user, so that the counter does not increate + // every time the user press refresh + HttpSession session = request.getSession(true); + // Set the session valid for 5 secs + session.setMaxInactiveInterval(5); + response.setContentType("text/plain"); + PrintWriter out = response.getWriter(); + if (session.isNew()) { + count++; + } + System.out.println("This site has been accessed " + count + " times."); + } + + @Override + public void init() throws ServletException { + dao = new FileDao(); + try { + count = dao.getCount(); + } catch (Exception e) { + getServletContext().log("An exception occurred in FileCounter", e); + throw new ServletException("An exception occurred in FileCounter" + + e.getMessage()); + } + } + + public void destroy() { + super.destroy(); + try { + dao.save(count); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + +} diff --git a/build/web/META-INF/MANIFEST.MF b/build/web/META-INF/MANIFEST.MF new file mode 100644 index 00000000..59499bce --- /dev/null +++ b/build/web/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/build/web/META-INF/context.xml b/build/web/META-INF/context.xml new file mode 100644 index 00000000..7587da9f --- /dev/null +++ b/build/web/META-INF/context.xml @@ -0,0 +1,2 @@ + + diff --git a/build/web/TestJSP.jsp b/build/web/TestJSP.jsp new file mode 100644 index 00000000..eb6a6482 --- /dev/null +++ b/build/web/TestJSP.jsp @@ -0,0 +1,26 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Insert title here + + + +<% + // This scriptlet declares and initializes "date" + System.out.println( "Evaluating date now" ); + java.util.Date date = new java.util.Date(); +%> +Hello! The time is now +<% + // This scriptlet generates HTML output + out.println( date ); + out.println("
Your machine address is : "); + out.println(request.getRemoteHost()); +%> +
+ + \ No newline at end of file diff --git a/build/web/WEB-INF/classes/.netbeans_automatic_build b/build/web/WEB-INF/classes/.netbeans_automatic_build new file mode 100644 index 00000000..e69de29b diff --git a/build/web/WEB-INF/classes/.netbeans_update_resources b/build/web/WEB-INF/classes/.netbeans_update_resources new file mode 100644 index 00000000..e69de29b diff --git a/build/web/WEB-INF/classes/DeleteServlet.class b/build/web/WEB-INF/classes/DeleteServlet.class new file mode 100644 index 00000000..b650cd5e Binary files /dev/null and b/build/web/WEB-INF/classes/DeleteServlet.class differ diff --git a/build/web/WEB-INF/classes/LoginHandler.class b/build/web/WEB-INF/classes/LoginHandler.class new file mode 100644 index 00000000..d49beac2 Binary files /dev/null and b/build/web/WEB-INF/classes/LoginHandler.class differ diff --git a/build/web/WEB-INF/classes/NewCommentServlet.class b/build/web/WEB-INF/classes/NewCommentServlet.class new file mode 100644 index 00000000..91a8cc70 Binary files /dev/null and b/build/web/WEB-INF/classes/NewCommentServlet.class differ diff --git a/build/web/WEB-INF/classes/NewPostServlet.class b/build/web/WEB-INF/classes/NewPostServlet.class new file mode 100644 index 00000000..c040be28 Binary files /dev/null and b/build/web/WEB-INF/classes/NewPostServlet.class differ diff --git a/build/web/WEB-INF/classes/NewUserServlet.class b/build/web/WEB-INF/classes/NewUserServlet.class new file mode 100644 index 00000000..e4d04986 Binary files /dev/null and b/build/web/WEB-INF/classes/NewUserServlet.class differ diff --git a/build/web/WEB-INF/classes/RestoreServlet.class b/build/web/WEB-INF/classes/RestoreServlet.class new file mode 100644 index 00000000..28142e4d Binary files /dev/null and b/build/web/WEB-INF/classes/RestoreServlet.class differ diff --git a/build/web/WEB-INF/classes/SignupHandler.class b/build/web/WEB-INF/classes/SignupHandler.class new file mode 100644 index 00000000..a1e16dca Binary files /dev/null and b/build/web/WEB-INF/classes/SignupHandler.class differ diff --git a/build/web/WEB-INF/classes/UpdatePost.class b/build/web/WEB-INF/classes/UpdatePost.class new file mode 100644 index 00000000..dfef2d90 Binary files /dev/null and b/build/web/WEB-INF/classes/UpdatePost.class differ diff --git a/build/web/WEB-INF/classes/UpdatePostServlet.class b/build/web/WEB-INF/classes/UpdatePostServlet.class new file mode 100644 index 00000000..9c367c91 Binary files /dev/null and b/build/web/WEB-INF/classes/UpdatePostServlet.class differ diff --git a/build/web/WEB-INF/classes/UpdateUserServlet.class b/build/web/WEB-INF/classes/UpdateUserServlet.class new file mode 100644 index 00000000..0cda078a Binary files /dev/null and b/build/web/WEB-INF/classes/UpdateUserServlet.class differ diff --git a/build/web/WEB-INF/classes/com/test/Test.class b/build/web/WEB-INF/classes/com/test/Test.class new file mode 100644 index 00000000..4b8d5abf Binary files /dev/null and b/build/web/WEB-INF/classes/com/test/Test.class differ diff --git a/build/web/WEB-INF/classes/fileBean.class b/build/web/WEB-INF/classes/fileBean.class new file mode 100644 index 00000000..2cbce5ba Binary files /dev/null and b/build/web/WEB-INF/classes/fileBean.class differ diff --git a/build/web/WEB-INF/classes/publishServlet.class b/build/web/WEB-INF/classes/publishServlet.class new file mode 100644 index 00000000..efd4c551 Binary files /dev/null and b/build/web/WEB-INF/classes/publishServlet.class differ diff --git a/build/web/WEB-INF/glassfish-web.xml b/build/web/WEB-INF/glassfish-web.xml new file mode 100644 index 00000000..13e0059f --- /dev/null +++ b/build/web/WEB-INF/glassfish-web.xml @@ -0,0 +1,10 @@ + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/build/web/WEB-INF/lib/javax.faces.jar b/build/web/WEB-INF/lib/javax.faces.jar new file mode 100644 index 00000000..81df198a Binary files /dev/null and b/build/web/WEB-INF/lib/javax.faces.jar differ diff --git a/build/web/WEB-INF/lib/jstl-api.jar b/build/web/WEB-INF/lib/jstl-api.jar new file mode 100644 index 00000000..e58a6dcf Binary files /dev/null and b/build/web/WEB-INF/lib/jstl-api.jar differ diff --git a/build/web/WEB-INF/lib/jstl-impl.jar b/build/web/WEB-INF/lib/jstl-impl.jar new file mode 100644 index 00000000..70ea9352 Binary files /dev/null and b/build/web/WEB-INF/lib/jstl-impl.jar differ diff --git a/build/web/WEB-INF/lib/mysql-connector-java-5.1.34-bin.jar b/build/web/WEB-INF/lib/mysql-connector-java-5.1.34-bin.jar new file mode 100644 index 00000000..0236900b Binary files /dev/null and b/build/web/WEB-INF/lib/mysql-connector-java-5.1.34-bin.jar differ diff --git a/build/web/WEB-INF/web.xml b/build/web/WEB-INF/web.xml new file mode 100644 index 00000000..90e1deb4 --- /dev/null +++ b/build/web/WEB-INF/web.xml @@ -0,0 +1,64 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + publishServlet + publishServlet + + + UpdateUserServlet + UpdateUserServlet + + + NewUserServlet + NewUserServlet + + + RestoreServlet + RestoreServlet + + + DeleteServlet + DeleteServlet + + + Faces Servlet + /faces/* + + + publishServlet + /publishServlet + + + UpdateUserServlet + /UpdateUserServlet + + + NewUserServlet + /NewUserServlet + + + RestoreServlet + /RestoreServlet + + + DeleteServlet + /DeleteServlet + + + + 30 + + + + awal.jsp + + diff --git a/build/web/assets/css/screen.css b/build/web/assets/css/screen.css new file mode 100644 index 00000000..2f1d4751 --- /dev/null +++ b/build/web/assets/css/screen.css @@ -0,0 +1,862 @@ +@import url(http://fonts.googleapis.com/css?family=Open+Sans); +@import url(http://fonts.googleapis.com/css?family=Questrial); + +/* Reset & Basics (Inspired by E. Meyers) +================================================== */ +html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, address, cite, code, em, img, small, strong, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, embed, figure, figcaption, footer, header, hgroup, menu, nav, section, summary, time, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; } +article, aside, details, figcaption, figure, footer, header, hgroup, menu, time, nav, section { + display: block; } +html, body, .wrapper { + min-height: 100%; +} + + +/* Body +================================================== */ +html, body { + height: 100%; +} +.wrapper { + min-height: 100%; + background : #fff; +} +body { + overflow-x: hidden; + font: 17px/28px ff-meta-serif-web-pro, "Georgia", serif; + color: #333; + background: #fff; +} + + +/* Typography +================================================== */ +h1, h2, h3, h4, h5, h6 { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-weight: normal; + text-transform: uppercase; + font-weight: 700; + color: #000; + text-rendering: optimizeLegibility; +} + +h1 { + font-size: 50px; + padding-bottom: 30px; +} + +h2 { + font-size: 45px; + padding-bottom: 25px; +} + +h3 { + font-size: 40px; + padding-bottom: 20px; +} + +h4 { + font-size: 35px; + padding-bottom: 15px; +} + +h5 { + font-size: 30px; + padding-bottom: 10px; +} + +p { + margin: 0 0 28px 0; +} + +strong { + font-weight: bold; +} +em { + font-style: italic; +} +sup { + line-height: 0; +} + +small { + font-size: 70%; +} + +cite { + font-size: 80%; + font-style: italic; + } + +/* Teaser +================================================== */ + +header#teaser h1 { + text-transform: none !important; + color: #333; + font-size: 28px !important; + font-weight: 300 !important; +} + + +/* Links +================================================== */ +a { + color: #F40034; + text-decoration: none; + -webkit-transition: color .2s ease-in-out; + -moz-transition: color .2s ease-in-out; + transition: color .2s ease-in-out; +} +a:hover { + color: #F40034; +} + +/* Layout +================================================== */ +/* White container that is the "page" */ +.wrapper { + max-width: 1500px; + margin: 0 auto; + background: #fff; +} + +/* Containers to keep content to a set width */ +.nav, +.art-header-inner, +.footer, +.art-list, +.abt, +.fourohfour { + width: 980px; +} +.nav, +.art-body-inner, +.footer, +.art-list, +.abt, +.fourohfour { + position: relative; + margin: 0 auto; +} + +/* Nav +================================================== */ +.nav { + position: relative; + top: 0; + left: 50%; + height: 70px; + padding-top: 40px; + margin-left: -490px; /* Half width of nav */ + border-bottom: 1px solid #333; + z-index: 2; +} +.nav.fixed { + position: fixed; +} +#logo { + float: left; +} +.nav-primary { + float: right; +} +.nav-primary li { + display: inline-block; + margin-left: 10px; + font-weight: 500; +} +#logo h1, +.nav-primary li, +.nav-primary li a { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-weight: 700; + font-size: 13px; + line-height: 30px; + color: #000; + text-transform: uppercase; +} + +#logo h1 { + height: 30px; + margin-left: 0px; + letter-spacing: 1px; + font-family: 'Questrial', sans-serif; + font-size: 30px; +} + +#logo h1 span{ + color: #F40034 !important; +} + +.nav li:first-child { + margin-left: 0; /* Remove left margin from the first nav li */ +} + +/* Home Page +================================================== */ + +div#home {} + +#home > div.cover { + max-width: 980px; + margin: 0px auto; + /*padding-top: 110px;*/ +} + +div.cover { + +} + +div.cover > img { + width: 100%; + height: 100%; +} + + +/* Article +================================================== */ +.art { + margin-top: -131px; +} +/* Header */ +.art-header { + height: 900px; + /* Background image is defined in the post */ + background-position: top center; + background-attachment: fixed; + overflow: hidden; +} +/* Contains the time, title and subtitle for an article */ +.art-header-inner { + position: relative; + top: 300px; + left: 50%; + margin-left: -490px; +} +.art-time, +.art-title, +.art-subtitle { + text-align: center; + text-transform: uppercase; +} +.art-time { + font-size: 14px; + line-height: 1.8; + letter-spacing: 4px; +} +.art-title { + font-size: 100px; + line-height: .9; + letter-spacing: -2px; + width: 100%; +} +.art-subtitle { + margin-top: 4px; + font-size: 14px; + line-height: 1.3; + letter-spacing: 4px; +} + +/* If small header, make few adjustments */ +.small .art-title { + font-size: 70px; + line-height: 65px; +} +.small.art-header-inner { + top: 320px; +} + +/* Body */ +.art-body { + position: relative; + width: 100%; + background: #fff; + z-index: 100; + -webkit-box-shadow: 0 -3px 3px rgba(0,0,0,.2); + -moz-box-shadow: 0 -3px 3px rgba(0,0,0,.2); + box-shadow: 0 -3px 3px rgba(0,0,0,.2); +} +.art-body-inner { + font-family: Georgia,Cambria,"Times New Roman",Times,serif; + max-width: 640px; + padding: 80px 0 50px; + letter-spacing: 0.01rem; + font-weight: 400; + font-style: normal; + font-size: 21px; + line-height: 1.5; +} +.art-body-inner a:hover { + border-bottom: 1px solid #F40034; + padding-bottom:2px; +} +.art-body-inner ul, +.art-body-inner ol { /* For lists in the article body */ + margin-bottom: 26px; +} +.art-body-inner ul li { + list-style: disc; +} + +.art-body-inner mark { + background-color: #fdffb6; + padding: 2px; + -webkit-box-shadow: #fdffb6 0 0 5px; + -moz-box-shadow: #fdffb6 0 0 5px; + box-shadow: #fdffb6 0 0 5px; +} + +.art-body-inner blockquote { + font-size: 16px; + background: #f9f9f9; + border-left: 10px solid #ccc; + margin: 1.5em 10px; + padding: 0.5em 10px; + quotes: "\201C""\201D""\2018""\2019"; +} + +.art-body-inner blockquote p:first-child:before { + color: #ccc; + content: "“"; + font-size: 4em; + line-height: 0.1em; + margin-right: 0.25em; + vertical-align: -0.4em; +} + +.art-body-inner blockquote p { + margin-bottom: 1.5em; +} + +.art-body-inner blockquote p:last-child { + margin-bottom: 0; +} + + +.dropcap { /* First character on articles */ + float: left; + margin: 47px 10px 20px 0; + font-size: 100px; + line-height: 0; +} +.art-subhead { /* Subheads are used to break up sections of an article */ + margin: 60px 0 15px; + font-size: 20px; + line-height: 28px; + letter-spacing: 3px; +} +.callout { /* Callouts are like large pullquotes */ + font-weight: bold; +} +.art-body-inner img { + max-width: 100%; + max-height: 600px; + margin-bottom: 26px; +} +.art-body-inner img.center { + display: block; + margin-left: auto; + margin-right: auto; +} +.art-body-inner .art-reference { + font-size: 80%; + color: #999; + margin-top: 50px; +} + +/* For simple, white background posts */ +.simple .art-body { + background: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + + +/* List of Articles +================================================== */ +.art-list { + padding: 120px 0 0; +} +.art-list-body { + position: relative; + overflow: hidden; +} +.art-list-item { + padding: 40px 0; + list-style: none; + overflow: hidden; + border-bottom: 1px solid #ccc; +} +.art-list-item:last-child { + border-bottom: none; +} +.art-list-title { + font-size: 26px; + line-height: 26px; + font-weight: 700; +} +.art-list-item-title-and-time { + float: left; + width: 30%; + margin-bottom: 10px; +} +.art-list-time { + font-size: 12px; + line-height: 20px; + letter-spacing: 2px; + text-transform: uppercase; + color: #999; +} +.art-list-title a { + color: #000; +} +.art-list-title a:hover { + color: #F40034; +} +.art-list-item p { + width: 65%; + float: left; + margin-left: 5%; + margin-bottom: 0; + font-size: 16px; + line-height: 24px; +} + + +/* Footer +================================================== */ +.footer { + padding: 30px 0 40px; + overflow: hidden; + border-top: 1px solid #ccc; +} +.footer, +.footer a { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-size: 13px; + text-transform: uppercase; + color: #777; +} +.footer a:hover { + color: #000; +} +.back-to-top, +.footer-nav, +.offsite-links { + width: 45%; + float: left; +} +.psi { + width:10%; + float:left; + text-align: center; +} +.footer-nav { + text-align: center; +} +.offsite-links { + text-align: right; +} +.footer .twitter-link:hover { + color: #0084B4; +} +.footer .instagram-link:hover { + color: #3F729B; +} +.footer .github-link:hover { + color: #c5376d; +} +.footer .caffein8-link:hover{ + color: black; +} +.footer .rss-link:hover { + color: #e85d24; +} +/* Remove prev & next links on loop */ +.art-list + .footer .footer-nav, +.abt + .footer .footer-nav { + text-indent: -9999px; + text-align: left; +} + + +/* White Reverse Theme +================================================== */ +/* Nav */ +.nav.white { + border-bottom-color: #fff; + border-bottom-color: rgba(255,255,255,.3); +} +.nav.white li a, +.nav.white li, +.nav.white #logo h1 { + color: #fff; + text-shadow: 0 0 8px rgba(0,0,0,.5); +} +.nav.white #logo h1 { + background-position: top center; +} + +nav.pagination{ + text-align: right; + padding-bottom: 25px; +} +/* Art header */ +.art-header.white { + background-color: #111; +} +.art-header.white .art-time, +.art-header.white .art-title, +.art-header.white .art-subtitle { + color: #fff; + text-shadow: 0 0 8px rgba(0,0,0,.5); +} + + +/* About page +================================================== */ +.abt { + padding: 200px 0 100px; + list-style: none; +} +.abt .abt-header { + font-size: 140px; + line-height: 1; + text-transform: none; +} +.abt .abt-subheader { + font-size: 24px; + font-style: italic; + text-transform: none; + color: #777; +} +.abt-body { + -moz-column-count: 2; + -moz-column-gap: 20px; + -webkit-column-count: 2; + -webkit-column-gap: 20px; + margin-bottom: 28px; +} +.abt-signoff { + line-height: 1.3; + font-style: italic; + color: #777; +} + +/* 404 page +================================================== */ +.fourohfour { + padding: 240px 0 100px; + text-align: center; +} + +/* Code +================================================== */ + +code, tt { +background: #ededee; +color: #3C4043; +font-size: 90%; +padding: 1px 3px; +} + +pre { + width: 92%; + overflow: auto; + margin: 2rem 0; + padding: 1rem 0.8rem 1rem 1.2rem; + color: #3f3b36; + border: 1px solid #ccc; + border-left: 1rem solid #ccc; + font: lighter 1.2rem/2rem monospace; + background: url(/assets/img/pre.png) repeat 0 -0.9rem; + background-size: 1px 4rem; +} + +pre code, tt { +font-size: inherit; +white-space: -moz-pre-wrap; +white-space: pre-wrap; +background: transparent; +border: none; +padding: 0; +} + + +.gist { + font-size: 14px; +} + + +/* Responsive +================================================== */ +@media only screen and (max-width: 1080px) { + /* Set all of the 980 containers to flexible width */ + .nav, + .art-body-inner, + .art-header-inner, + .footer, + .art-list, + .abt, + .fourohfour { + width: 90%; + } + .nav, + .art-header-inner { + margin-left: -45%; + } +} + +@media only screen and (max-width: 1024px) { + /* Everything becomes scrolling and non-fading */ + .nav, + .nav.fixed { + position: relative; + opacity: 1 !important; /* Important to override JS values */ + display: inline-block; + } + .art-header-inner { + position: relative; + top: 0 !important; /* Important to override JS values */ + margin-top: 240px !important; /* Important to override JS values */ + opacity: 1 !important; /* Important to override JS values */ + } + /* Articles no longer have fixed heights */ + .art-header { + height: auto; + padding-bottom: 100px; + background-size: cover !important; + background-attachment: scroll; + } + /* Remove bottom space out if articles doesn't have a background */ + .simple .art-header { + padding-bottom: 0; + } + .art-list { + padding-top: 0; + } + .abt { + padding: 40px 0; + } + .fourohfour { + padding: 80px 0 60px; + } +} + +@media only screen and (max-width: 780px) { + .art-body-inner ul, + .art-body-inner ol { + margin-left: 20px; + } + .art-title { + letter-spacing: 0; + } + .art-subtitle, + .art-time { + font-size: 12px; + } + .nav { + padding-top: 25px; + height: 55px; + } + .art-list-item-title-and-time, + .art-list-item p { + float: none; + width: auto; + margin-left: 0; + } + .abt-body { + -moz-column-count: 1; + -webkit-column-count: 1; + } +} + +@media only screen and (max-width: 500px) { + .nav-primary li { + margin-left: 10px; + } + .nav #logo h1 { + font-size: 16px; + letter-spacing: -1px; + } + .nav li a { + font-size: 12px; + } + .art-header { + padding-bottom: 50px; + } + .art-header-inner { + margin-top: 190px !important; + } + .art-body-inner { + padding-top: 30px; + } + body { + font-size: 15px; + line-height: 24px; + } + p { + margin-bottom: 24px; + } + .footer { + padding: 10px 0 20px; + } + .back-to-top, + .footer-nav { + width: 50%; + } + .back-to-top { + text-align: left; + } + .footer-nav { + text-align: right; + } + .offsite-links { + float: left; + width: 100%; + text-align: left; + } + .offsite-links a { + font-size: 12px; + } + .art-list + .footer .footer-nav { + display: none; + } + .abt .abt-header { + font-size: 80px; + } + .abt .abt-subheader { + font-size: 18px; + } +} + + +/* Misc +================================================== */ +::selection { + background: #000; + color: #fff; +} +::-moz-selection { + background: #000; + color: #fff; +} +img.left { + float: left; + margin-right: 20px; +} +img.right { + float: right; + margin-left: 20px; +} +/* Clearfixing pile */ +.nav:before, +.art-body-inner:before, +.footer:before, +.art-list:before { + content:""; + display:table; +} +.nav:after, +.art-body-inner:after, +.footer:after, +.art-list:after { + clear:both; +} +.nav, +.art-body-inner, +.footer, +.art-list { + zoom:1; /* For IE 6/7 (trigger hasLayout) */ +} + + +@-webkit-keyframes le-fade { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +@-moz-keyframes le-fade { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +.art-header-inner { + -webkit-animation: le-fade .5s 0 1 ease-out; + -moz-animation: le-fade .5s 0 1 ease-out; +} + +.art-list, +.nav, +.abt, +.art-body { + -webkit-animation: le-fade .5s 0s 1 ease-out; + -moz-animation: le-fade .5s 0s 1 ease-out; +} + +hr.featured-article { + padding: 0; + border: none; + border-top: medium double #bbb; + color: #bbb; + text-align: center; +} +hr.featured-article:after { + content: "✭ Featured Article ✭"; + display: inline-block; + position: relative; + top: -0.8em; + font-size: 1.2em; + padding: 0 0.6em; + background: white; +} + +/* FORM */ + +#contact-area { + width: 600px; + margin-top: 25px; +} + +#contact-area input, #contact-area textarea { + padding: 5px; + width: 471px; + font-family: Helvetica, sans-serif; + margin: 0px 0px 10px 0px; + border: 2px solid #ccc; +} + +#contact-area textarea { + height: 90px; +} + +#contact-area textarea:focus, #contact-area input:focus { + border: 2px solid #900; +} + +#contact-area input.submit-button { + width: 100px; + +} + +label { + float: left; + text-align: right; + margin-right: 15px; + width: 100px; + padding-top: 5px; +} \ No newline at end of file diff --git a/build/web/assets/img/favicon.ico b/build/web/assets/img/favicon.ico new file mode 100644 index 00000000..40b40ed3 Binary files /dev/null and b/build/web/assets/img/favicon.ico differ diff --git a/build/web/assets/img/pre.png b/build/web/assets/img/pre.png new file mode 100644 index 00000000..7f48517b Binary files /dev/null and b/build/web/assets/img/pre.png differ diff --git a/build/web/awal.jsp b/build/web/awal.jsp new file mode 100644 index 00000000..50de4417 --- /dev/null +++ b/build/web/awal.jsp @@ -0,0 +1,18 @@ +<%-- + Document : awal + Created on : Nov 25, 2014, 3:24:43 PM + Author : Riady +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + +<% response.sendRedirect("faces/index.jsp"); %> + + + + JSP Page + + +

Hello World!

+ + diff --git a/build/web/cobaupload.jsp b/build/web/cobaupload.jsp new file mode 100644 index 00000000..0d3eb892 --- /dev/null +++ b/build/web/cobaupload.jsp @@ -0,0 +1,105 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + + + +
+ + + +
+ + + + +
+ + + +
+ + + + + + + +
\ No newline at end of file diff --git a/build/web/delete_post.jsp b/build/web/delete_post.jsp new file mode 100644 index 00000000..8fdd7f45 --- /dev/null +++ b/build/web/delete_post.jsp @@ -0,0 +1,49 @@ + +<%@page import="java.sql.Statement"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %> + + + + +Insert title here + + + + +<% + Connection conn; + PreparedStatement pState; + Random random = new Random(); + + try { + Class.forName("com.mysql.jdbc.Driver"); + int updateQuery = 0; + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + pState = conn.prepareStatement("UPDATE post SET status = 'deleted' WHERE post_id = ?"); + pState.setString(1, String.valueOf(request.getParameter("postId"))); + updateQuery = pState.executeUpdate(); + } catch(Exception e){out.println("Error" + e);} + response.sendRedirect("index.jsp"); + + %> + + + + + + + \ No newline at end of file diff --git a/build/web/delete_user.jsp b/build/web/delete_user.jsp new file mode 100644 index 00000000..974228f8 --- /dev/null +++ b/build/web/delete_user.jsp @@ -0,0 +1,49 @@ + +<%@page import="java.sql.Statement"%> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %> + + + + +Insert title here + + + + +<% + Connection conn; + PreparedStatement pState; + Random random = new Random(); + + try { + Class.forName("com.mysql.jdbc.Driver"); + int updateQuery = 0; + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + pState = conn.prepareStatement("DELETE FROM user WHERE username = ?"); + pState.setString(1, String.valueOf(request.getParameter("userName"))); + updateQuery = pState.executeUpdate(); + } catch(Exception e){out.println("Error" + e);} + response.sendRedirect("faces/man_user.jsp"); + + %> + + + + + + + \ No newline at end of file diff --git a/build/web/deleted_post.jsp b/build/web/deleted_post.jsp new file mode 100644 index 00000000..f28422c1 --- /dev/null +++ b/build/web/deleted_post.jsp @@ -0,0 +1,141 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + + +<% + InitialContext ctx; + DataSource ds; + Connection conn; + Statement stmt; + ResultSet rs; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + stmt = conn.createStatement(); + rs = stmt.executeQuery("SELECT * FROM post WHERE status='deleted' ORDER BY post_date DESC "); +%> +
+ + + +
+
+ +
+
+ + + +
+ + + + + + +
+ + anda tidak berhak!! + + +
\ No newline at end of file diff --git a/build/web/gfv3ee6.dpf b/build/web/gfv3ee6.dpf new file mode 100644 index 00000000..e69de29b diff --git a/build/web/index.jsp b/build/web/index.jsp new file mode 100644 index 00000000..9dde22bd --- /dev/null +++ b/build/web/index.jsp @@ -0,0 +1,145 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + + +<% + InitialContext ctx; + DataSource ds; + Connection conn; + Statement stmt; + ResultSet rs; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + stmt = conn.createStatement(); + rs = stmt.executeQuery("SELECT * FROM post WHERE status = 'published' ORDER BY post_date DESC"); +%> +
+ + + +
+
+ +
+
+ + + +
+ + + + + + + +
\ No newline at end of file diff --git a/build/web/man_user.jsp b/build/web/man_user.jsp new file mode 100644 index 00000000..fdd13bc9 --- /dev/null +++ b/build/web/man_user.jsp @@ -0,0 +1,138 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + + +<% + InitialContext ctx; + DataSource ds; + Connection conn; + Statement stmt; + ResultSet rs; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + stmt = conn.createStatement(); + rs = stmt.executeQuery("SELECT * FROM user"); +%> +
+ + + +
+
+ +
+
+ + + +
+ + + + + + + +
\ No newline at end of file diff --git a/build/web/new_comment.jsp b/build/web/new_comment.jsp new file mode 100644 index 00000000..7498b248 --- /dev/null +++ b/build/web/new_comment.jsp @@ -0,0 +1,54 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %> + +Insert title here + + + + +<% + Connection conn; + PreparedStatement pState; + Random random = new Random(); + + try { + long commentId = random.nextLong() + 1000000000; + String comment_id = String.valueOf(commentId); + String nama = request.getParameter("Nama"); + String post_id = request.getParameter("post_id"); + String comment_date = request.getParameter("comment_date"); + String komentar = request.getParameter("Komentar"); + String email = request.getParameter("Email"); + Class.forName("com.mysql.jdbc.Driver").newInstance(); + int updateQuery = 0; + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + if(comment_id != null && nama != null && post_id != null && comment_date != null && email != null && komentar != null){ + pState = conn.prepareStatement("INSERT INTO `comment` (`post_id`, `comment_id`, `email`, `nama`, `komentar`, `comment_date`) VALUES (?,?,?,?,?,?)"); + pState.setString(1, post_id); + pState.setString(2, comment_id); + pState.setString(3, email); + pState.setString(4, nama); + pState.setString(5, komentar); + pState.setString(6, comment_date); + updateQuery = pState.executeUpdate(); + } + + out.print("
  • \n"+ + "
    \n"+ + "

    "+ nama +"

    \n"+ + "
    "+ comment_date +"
    \n"+ + "
    \n"+ + "

    " + komentar + "

    \n"+ + "
  • "); + } catch(Exception e){out.println("Error" + e);} + %> + +
    + + \ No newline at end of file diff --git a/build/web/new_post.html b/build/web/new_post.html new file mode 100644 index 00000000..b7bd3fb2 --- /dev/null +++ b/build/web/new_post.html @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Tambah Post + + + + + + +
    + + + +
    + + +

    -

    + +
    +
    +

    Tambah Post

    + +
    +
    + + + + +
    + + +
    +
    +
    +
    + +
    + + + +
    + + + + + + + + \ No newline at end of file diff --git a/build/web/new_post.jsp b/build/web/new_post.jsp new file mode 100644 index 00000000..a3c88c7e --- /dev/null +++ b/build/web/new_post.jsp @@ -0,0 +1,45 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %> + + +Load new post + + +<% + Connection conn; + PreparedStatement pState; + Random random = new Random(); + + try { + long postId = random.nextLong() + 1000000000; + String post_id = String.valueOf(postId); + String tittle = request.getParameter("Judul"); + String postDate = request.getParameter("Tanggal"); + String konten = request.getParameter("Konten"); + Class.forName("com.mysql.jdbc.Driver").newInstance(); + int updateQuery = 0; + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + if(post_id != null && tittle != null && postDate != null && konten != null){ + pState = conn.prepareStatement("INSERT INTO post (post_id, tittle, post_date, konten)VALUES (?,?,?,?)"); + pState.setString(1, post_id); + pState.setString(2, tittle); + pState.setString(3, postDate); + pState.setString(4, konten); + updateQuery = pState.executeUpdate(); + } + } catch(Exception e){out.println("Error" + e);} + response.sendRedirect("faces/index.jsp"); + + %> + + + + + + \ No newline at end of file diff --git a/build/web/new_user.html b/build/web/new_user.html new file mode 100644 index 00000000..52886cac --- /dev/null +++ b/build/web/new_user.html @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Tambah Post + + + + + + +
    + + + +
    + + +

    -

    + +
    +
    +

    Tambah User

    + +
    +
    + + + + +
    + +
    + +
    + +

    + +
    +
    +
    +
    + +
    + + + +
    + + + + + + + + \ No newline at end of file diff --git a/build/web/new_user.jsp b/build/web/new_user.jsp new file mode 100644 index 00000000..08ffee5a --- /dev/null +++ b/build/web/new_user.jsp @@ -0,0 +1,47 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %> + + +Load new post + + +<% + InitialContext ctx; + Connection conn; + PreparedStatement pState; + int updateQuery = 0; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + String username = request.getParameter("Username"); + String nama = request.getParameter("Nama"); + String email = request.getParameter("Email"); + String role = request.getParameter("Role"); + String password = request.getParameter("Password"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + if(username != null && password != null && nama != null && email != null && role != null){ + pState = conn.prepareStatement("INSERT INTO user (username, password, nama, email, role)VALUES (?,?,?,?,?)"); + pState.setString(1, username); + pState.setString(2, password); + pState.setString(3, nama); + pState.setString(4, email); + pState.setString(5, role); + updateQuery = pState.executeUpdate(); + } + } catch(Exception e){out.println("Error" + e);} + response.sendRedirect("faces/man_user.jsp"); + + %> + + + + + + \ No newline at end of file diff --git a/build/web/newpost.jsp b/build/web/newpost.jsp new file mode 100644 index 00000000..450211ae --- /dev/null +++ b/build/web/newpost.jsp @@ -0,0 +1,187 @@ +<%-- + Document : newpost + Created on : Nov 25, 2014, 3:58:29 PM + Author : Riady +--%> + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Tambah Post + + + + + + +
    + + + +
    + + +

    -

    + +
    +
    +

    Tambah Post

    + +
    +
    + + + + +
    + + +
    +
    +
    +
    + +
    + + + +
    + + + + + + + +
    + +
    \ No newline at end of file diff --git a/build/web/newuser.jsp b/build/web/newuser.jsp new file mode 100644 index 00000000..5cbb352f --- /dev/null +++ b/build/web/newuser.jsp @@ -0,0 +1,143 @@ +<%-- + Document : newpost + Created on : Nov 25, 2014, 3:58:29 PM + Author : Riady +--%> + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Tambah Post + + + + + + +
    + + + +
    + + +

    -

    + +
    +
    +

    Tambah User

    + +
    +
    + + + + +
    + +
    + +
    + +

    + +
    +
    +
    +
    + +
    + + + +
    + + + + + + + +
    + +
    \ No newline at end of file diff --git a/build/web/post.jsp b/build/web/post.jsp new file mode 100644 index 00000000..9bea91cd --- /dev/null +++ b/build/web/post.jsp @@ -0,0 +1,259 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Apa itu Simple Blog? + + + + + + + +
    + + + + + +
    + + <% + InitialContext ctx; + DataSource ds; + Connection conn; + Statement state; + ResultSet rsPost; + ResultSet rsComment; + + int updateQuery = 0; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + String query = "SELECT * FROM post WHERE post_id = '" + String.valueOf(request.getParameter("postId") + "'"); + state = conn.createStatement(); + rsPost = state.executeQuery(query); + rsPost.next(); + %> + +
    +
    + +

    <% out.print(rsPost.getString("tittle")); %>

    +

    +
    +
    + +
    +
    +
    +

    <% out.print(rsPost.getString("konten")); %>

    + <% + }catch(Exception e){out.print(""+e);} + %> +
    + + <%try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + String query = "SELECT * FROM comment WHERE post_id = '" + String.valueOf(request.getParameter("postId") + "' ORDER BY comment_id DESC"); + state = conn.createStatement(); + rsComment = state.executeQuery(query); + %> + +

    Komentar

    + +
    + + +
    + + + + + +
    + + + + + + + + +
    + +
    + + "> + <% java.util.Date date = new java.util.Date(); + java.sql.Date dateSQL = new java.sql.Date(date.getYear(), date.getMonth(), date.getDate());%> + +
    +
    + + +
    +
    + <%}catch(Exception e){out.print(""+e);} %> +
    + + + +
    + + + + + + + + +
    \ No newline at end of file diff --git a/build/web/publish_post.jsp b/build/web/publish_post.jsp new file mode 100644 index 00000000..c85ceeaa --- /dev/null +++ b/build/web/publish_post.jsp @@ -0,0 +1,142 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + +<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> +<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> + + + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + + +<% + InitialContext ctx; + DataSource ds; + Connection conn; + Statement stmt; + ResultSet rs; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + stmt = conn.createStatement(); + rs = stmt.executeQuery("SELECT * FROM post WHERE status='unpublished' ORDER BY post_date DESC "); +%> +
    + + + +
    +
    + +
    +
    + + + +
    + + + + + + +
    + + anda tidak berhak!! + + +
    \ No newline at end of file diff --git a/build/web/readme.md b/build/web/readme.md new file mode 100644 index 00000000..5e7e48f5 --- /dev/null +++ b/build/web/readme.md @@ -0,0 +1,39 @@ +# Simple Blog Java + +Tugas 2 IF3110. + +![Simple Blog](http://i655.photobucket.com/albums/uu275/sonnylazuardi/ss-5.jpg) + +## Deskripsi + +Gunakan template ini untuk membuat sebuah blog sederhana dengan menggunakan bahasa pemrograman PHP. + +## Spesifikasi + +Spesifikasi untuk Tugas II IF3110 dapat diakses pada pranala berikut: + +https://www.dropbox.com/sh/ig1hf108ad9fqxi/AAA2PMjPFICSFo3ypdrHl39La?dl=0 + +## Deliverable + +Tiap-tiap Kelompok Membuat Organizationnya masing-masing, dengan langkah: + +1. Klik tanda Tambah disamping username pada Github, Pilih Create New Organization + +2. Buat Organisasi dengan Nama : IF3110-II-Nomor_Kelompok . Nomor Kelompok dapat diakses [disini](https://docs.google.com/spreadsheets/d/1Y-FGJ_feIVYNRv-o0ycBXyfAiKMFXKA17cvw3Mhjd1A/edit?usp=sharing) + +3. Masukkan email address salah satu anggota untuk billing email ( bebas ). + +4. Undang anggota kelompok untuk menjadi anggota Organisasi. + +5. Lakukan Fork Repository ini ke Organisasi yang baru dibentuk + +6. Setelah selesai mengerjakan, lakukan Pull Request. + +## Lisensi + +© 2014 Asisten IF3110 + +Yogi | [Sonny](http://github.com/sonnylazuardi) | Fathan | Renusa | Kelvin | Yanuar + +Dosen: [Yudistira Dwi Wardhana](http://github.com/yudis) \ No newline at end of file diff --git a/build/web/update.jsp b/build/web/update.jsp new file mode 100644 index 00000000..675298b5 --- /dev/null +++ b/build/web/update.jsp @@ -0,0 +1,49 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %> + + +Insert title here + + + +<% + InitialContext ctx; + DataSource ds; + Connection conn; + PreparedStatement pState; + ResultSet rs; + int updateQuery = 0; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + String post_id = request.getParameter("post_id"); + String tittle = request.getParameter("Judul"); + String postDate = request.getParameter("Tanggal"); + String konten = request.getParameter("Konten"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + if(post_id != null && tittle != null && postDate != null && konten != null){ + pState = conn.prepareStatement("UPDATE `post` set `tittle` = ?, `post_date` = ?, `konten` = ? WHERE `post_id` = ?"); + pState.setString(1, tittle); + pState.setString(2, postDate); + pState.setString(3, konten); + pState.setString(4, post_id); + updateQuery = pState.executeUpdate(); + } + }catch(Exception e){out.println(""+e);} + response.sendRedirect("index.jsp"); +%> + + + + + + \ No newline at end of file diff --git a/build/web/update_post.jsp b/build/web/update_post.jsp new file mode 100644 index 00000000..1a4955ed --- /dev/null +++ b/build/web/update_post.jsp @@ -0,0 +1,190 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Tambah Post + + + + + + +
    + + + +
    + + +

    -

    + +
    +
    +

    Update Post

    + + <% + InitialContext ctx; + DataSource ds; + Connection conn; + Statement state; + + ResultSet rs; + int updateQuery = 0; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + String query = "SELECT * FROM post WHERE post_id = '" + String.valueOf(request.getParameter("postId") + "'"); + state = conn.createStatement(); + rs = state.executeQuery(query); + rs.next(); + %> + + + +
    +
    + + "> + + "> + +
    + + + + "> +
    + <%}catch(Exception e){out.println(""+e);} %> +
    +
    +
    + +
    + + + +
    + + + + + + + + + \ No newline at end of file diff --git a/build/web/update_user.jsp b/build/web/update_user.jsp new file mode 100644 index 00000000..be9262ff --- /dev/null +++ b/build/web/update_user.jsp @@ -0,0 +1,131 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver" %> + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Tambah Post + + + + +
    + + + +
    + + +

    -

    + +
    +
    +

    Update User

    + + <% + InitialContext ctx; + DataSource ds; + Connection conn; + Statement state; + + ResultSet rs; + int updateQuery = 0; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + String query = "SELECT * FROM user WHERE username = '" + String.valueOf(request.getParameter("userName") + "'"); + state = conn.createStatement(); + rs = state.executeQuery(query); + rs.next(); + %> + + + +
    +
    + + "> + + "> +
    + "> +
    + "> +
    + "> +

    + +
    + <%}catch(Exception e){out.println(""+e);} %> +
    +
    +
    + +
    + + + +
    + + + + + + + + + \ No newline at end of file diff --git a/build/web/updateuser.jsp b/build/web/updateuser.jsp new file mode 100644 index 00000000..6df69bbd --- /dev/null +++ b/build/web/updateuser.jsp @@ -0,0 +1,49 @@ + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<%@ page import="java.sql.*, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*" +%> +<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %> + + +Insert title here + + + +<% + InitialContext ctx; + Connection conn; + PreparedStatement pState; + int updateQuery = 0; + + try { + ctx = new InitialContext(); + Class.forName("com.mysql.jdbc.Driver"); + String username = request.getParameter("Username"); + String nama = request.getParameter("Nama"); + String email = request.getParameter("Email"); + String role = request.getParameter("Role"); + String password = request.getParameter("Password"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + if(username != null && password != null && nama != null && email != null && role != null){ + pState = conn.prepareStatement("UPDATE `user` set `nama` = ?, `email` = ?, `role` = ?, `password` = ? WHERE `username` = ?"); + pState.setString(1, nama); + pState.setString(2, email); + pState.setString(3, role); + pState.setString(4, password); + pState.setString(5, username); + updateQuery = pState.executeUpdate(); + } + }catch(Exception e){out.println(""+e);} + response.sendRedirect("man_user.jsp"); +%> + + + + + + \ No newline at end of file diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml new file mode 100644 index 00000000..2d5f8778 --- /dev/null +++ b/nbproject/ant-deploy.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 00000000..57deead8 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1448 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 00000000..73c73281 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=8f926b26 +build.xml.script.CRC32=7aa26648 +build.xml.stylesheet.CRC32=651128d4@1.65.1.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=8f926b26 +nbproject/build-impl.xml.script.CRC32=2578fbd4 +nbproject/build-impl.xml.stylesheet.CRC32=d659eb7a@1.65.1.1 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 00000000..ad9b8f27 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,96 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=JSP +build.classes.dir=${build.web.dir}/WEB-INF/classes +build.classes.excludes=**/*.java,**/*.form +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +build.web.dir=${build.dir}/web +build.web.excludes=${build.classes.excludes} +client.urlPart= +compile.jsps=false +conf.dir=${source.root}/conf +debug.classpath=${build.classes.dir}:${javac.classpath} +debug.test.classpath=\ + ${run.test.classpath} +display.browser=true +# Files to be excluded from distribution war +dist.archive.excludes= +dist.dir=dist +dist.ear.war=${dist.dir}/${war.ear.name} +dist.javadoc.dir=${dist.dir}/javadoc +dist.war=${dist.dir}/${war.name} +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +file.reference.mysql-connector-java-5.1.34-bin.jar=C:\\Users\\Viktor Buntoro\\Dropbox\\IF\\WBD\\mysql-connector-java-5.1.34-bin.jar +file.reference.mysql-connector-java-5.1.34-bin.jar-1=D:\\mysql-connector-java-5.1.34-bin.jar +file.reference.WBD_Project-src=../WBD Project/src +includes=** +j2ee.compile.on.save=true +j2ee.copy.static.files.on.save=true +j2ee.deploy.on.save=true +j2ee.platform=1.7-web +j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +javac.classpath=\ + ${file.reference.mysql-connector-java-5.1.34-bin.jar}:\ + ${libs.jsf20.classpath}:\ + ${libs.jstl.classpath}:\ + ${file.reference.mysql-connector-java-5.1.34-bin.jar-1} +# Space-separated list of extra javac options +javac.compilerargs= +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +lib.dir=${web.docbase.dir}/WEB-INF/lib +persistence.xml.dir=${conf.dir} +platform.active=default_platform +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs= +source.encoding=UTF-8 +source.root=src +src.src.dir=${file.reference.WBD_Project-src} +test.src.dir=test +war.content.additional= +war.ear.name=${war.name} +war.name=tubes.war +web.docbase.dir=WebContent +webinf.dir=WebContent/WEB-INF diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 00000000..f584a8e7 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,34 @@ + + + org.netbeans.modules.web.project + + + tubes + 1.6.5 + + + ${file.reference.mysql-connector-java-5.1.34-bin.jar} + + + ${libs.jsf20.classpath} + WEB-INF/lib + + + ${libs.jstl.classpath} + WEB-INF/lib + + + ${file.reference.mysql-connector-java-5.1.34-bin.jar-1} + WEB-INF/lib + + + + + + + + + + + + diff --git a/src/DeleteServlet.java b/src/DeleteServlet.java new file mode 100644 index 00000000..9d0e720f --- /dev/null +++ b/src/DeleteServlet.java @@ -0,0 +1,89 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +import com.mysql.jdbc.Connection; +import com.mysql.jdbc.PreparedStatement; +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.DriverManager; +import java.util.Random; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author Riady + */ +public class DeleteServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException + { + Connection conn; + PreparedStatement pState; + Random random = new Random(); + PrintWriter out = response.getWriter(); + try { + Class.forName("com.mysql.jdbc.Driver"); + int updateQuery = 0; + conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + pState = (PreparedStatement) conn.prepareStatement("DELETE FROM post WHERE post_id = ?"); + pState.setString(1, String.valueOf(request.getParameter("postId"))); + updateQuery = pState.executeUpdate(); + } catch(Exception e){out.println("Error" + e);} + response.sendRedirect("faces/deleted_post.jsp"); + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException + { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException + { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/src/LoginHandler.java b/src/LoginHandler.java new file mode 100644 index 00000000..870aec24 --- /dev/null +++ b/src/LoginHandler.java @@ -0,0 +1,188 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author Riady + */ +import com.mysql.jdbc.Connection; +import com.mysql.jdbc.Statement; +import java.io.IOException; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.SessionScoped; +import javax.faces.context.FacesContext; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +@ManagedBean(name = "loginHandler",eager=true) +@SessionScoped +public class LoginHandler { + private String username; + private String password; + private String email; + private String cookiename = "username"; + private int expiry = 60*30; + private int role; //0=guest, 1=owner, 2=editor, 3=admin + private Connection con; + private boolean loginAttempted = false; + private boolean loginSucc = false; + private String test; + + + + public int getRole(){ + return role; + } + + public boolean getLoginAttempted(){ + return loginAttempted&&!loginSucc; + } + + public boolean getLoginSucc(){ + return loginSucc; + } + + public LoginHandler(){ + username=""; + password=""; + email=""; + role=0; + } + + public String getMail() { + return email; + } + + public void setMail(String emaill) { + email = emaill; + } + + public void setUsername(String user){ + username=user; + } + + public String getUsername(){ + return username; + } + + public void setPassword(String pass){ + password=pass; + } + + public String getPassword(){ + return password; + } + + public void login() throws IOException, SQLException, ClassNotFoundException{ + execute(); + if(!getLoginAttempted()){ + FacesContext facesContext = FacesContext.getCurrentInstance(); + Cookie userName = new Cookie(cookiename, username); + userName.setMaxAge(expiry); + HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); + response.addCookie(userName); + response.sendRedirect("index.jsp"); + } + + } + + public void makeConnection() throws ClassNotFoundException, SQLException{ + Class.forName("com.mysql.jdbc.Driver"); + con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db","root",""); + + } + + public void execute() throws SQLException, ClassNotFoundException{ + boolean loginB = false; + makeConnection(); + Statement st = (Statement)con.createStatement(); + ResultSet rs; + rs = st.executeQuery("SELECT * FROM user WHERE username='"+username+"'"); + while(rs.next()&&!loginB){ + if(rs.getString("password").equals(password)){ + loginB=true; + if(rs.getString("role").equals("owner")){ + role=1; + } + else if(rs.getString("role").equals("editor")){ + role=2; + } + else if(rs.getString("role").equals("admin")){ + role=3; + } + email = rs.getString("email"); + } + + + } + loginSucc=loginB; + loginAttempted = true; + con.close(); + } + + public void logout() throws IOException{ + FacesContext facesContext = FacesContext.getCurrentInstance(); + Cookie cookie =getCookie(); + cookie.setValue(null); + cookie.setMaxAge(0); + HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); + response.addCookie(cookie); + response.sendRedirect("faces/index.jsp"); + role=0; + } + + + + public Cookie getCookie() { + + FacesContext facesContext = FacesContext.getCurrentInstance(); + + HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); + Cookie cookie = null; + + Cookie[] userCookies = request.getCookies(); + if (userCookies != null && userCookies.length > 0 ) { + for (int i = 0; i < userCookies.length; i++) { + if (userCookies[i].getName().equals(cookiename)) { + cookie = userCookies[i]; + return cookie; + } + } + } + return null; + } + + public boolean isLogin(){ + Cookie cookie = getCookie(); + if(cookie==null){ + return false; + } + else{ + return cookie.getValue()!=null; + } + } + + public boolean isGuest(){ + return role==0; + } + + public boolean isOwner(){ + return role==1; + } + + public boolean isEditor(){ + return role==2; + } + + public boolean isAdmin(){ + return role==3; + } +} diff --git a/src/NewCommentServlet.java b/src/NewCommentServlet.java new file mode 100644 index 00000000..faa2aa66 --- /dev/null +++ b/src/NewCommentServlet.java @@ -0,0 +1,43 @@ + + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class NewCommentServlet + */ +@WebServlet("/NewCommentServlet") +public class NewCommentServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public NewCommentServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + RequestDispatcher reqDis = request.getRequestDispatcher("new_comment.jsp"); + reqDis.forward(request, response); + } + +} diff --git a/src/NewPostServlet.java b/src/NewPostServlet.java new file mode 100644 index 00000000..5937a180 --- /dev/null +++ b/src/NewPostServlet.java @@ -0,0 +1,38 @@ + + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.jasper.tagplugins.jstl.core.Out; + +/** + * Servlet implementation class NewPostServlet + */ +@WebServlet("/NewPostServlet") +public class NewPostServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + RequestDispatcher reqDis = request.getRequestDispatcher("new_post.jsp"); + reqDis.forward(request, response); + } + +} diff --git a/src/NewUserServlet.java b/src/NewUserServlet.java new file mode 100644 index 00000000..cc994817 --- /dev/null +++ b/src/NewUserServlet.java @@ -0,0 +1,43 @@ + + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class UpdatePostServlet + */ +@WebServlet("/NewUserServlet") +public class NewUserServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public NewUserServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + RequestDispatcher reqDis = request.getRequestDispatcher("new_user.jsp"); + reqDis.forward(request, response); + } + +} diff --git a/src/RestoreServlet.java b/src/RestoreServlet.java new file mode 100644 index 00000000..239fbd61 --- /dev/null +++ b/src/RestoreServlet.java @@ -0,0 +1,89 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +import com.mysql.jdbc.Connection; +import com.mysql.jdbc.PreparedStatement; +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.DriverManager; +import java.util.Random; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author Riady + */ +public class RestoreServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException + { + Connection conn; + PreparedStatement pState; + Random random = new Random(); + PrintWriter out = response.getWriter(); + try { + Class.forName("com.mysql.jdbc.Driver"); + int updateQuery = 0; + conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + pState = (PreparedStatement) conn.prepareStatement("UPDATE post SET status = 'unpublished' WHERE post_id = ?"); + pState.setString(1, String.valueOf(request.getParameter("postId"))); + updateQuery = pState.executeUpdate(); + } catch(Exception e){out.println("Error" + e);} + response.sendRedirect("deleted_post.jsp"); + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException + { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException + { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/src/SignupHandler.java b/src/SignupHandler.java new file mode 100644 index 00000000..a74c8b3e --- /dev/null +++ b/src/SignupHandler.java @@ -0,0 +1,82 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author Riady + */ +import com.mysql.jdbc.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import javax.faces.bean.ManagedBean; + + +@ManagedBean(name = "signupHandler",eager=true) +public class SignupHandler { + private String username; + private String password; + private String password2; + private String nama; + private int role; //0=guest, 1=owner, 2=editor, 3=admin + private Connection con; + + public SignupHandler(){ + username=""; + password=""; + role=2; + } + + public void setNama(String snama){ + nama=snama; + } + + public String getNama(){ + return nama; + } + + public void setUsername(String user){ + username=user; + } + + public String getUsername(){ + return username; + } + + public void setPassword(String pass){ + password=pass; + } + + public String getPassword(){ + return password; + } + + + public void makeConnection() throws ClassNotFoundException, SQLException{ + Class.forName("com.mysql.jdbc.Driver"); + con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db","root",""); + + } + + public void execute() throws SQLException, ClassNotFoundException{ + if(password==password2){ + makeConnection(); + PreparedStatement st; + st = (PreparedStatement)con.prepareStatement("INSERT INTO user (username,password,nama,role) VALUES (?,?,?,?)"); + st.setString(1,username); + st.setString(2,password); + st.setString(3,nama); + st.setString(4,"editor"); + } + + + } + +} + + + + \ No newline at end of file diff --git a/src/UpdatePost.java b/src/UpdatePost.java new file mode 100644 index 00000000..27fea451 --- /dev/null +++ b/src/UpdatePost.java @@ -0,0 +1,43 @@ + + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class UpdatePost + */ +@WebServlet("/UpdatePost") +public class UpdatePost extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public UpdatePost() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + RequestDispatcher reqDis = request.getRequestDispatcher("index.jsp"); + reqDis.forward(request, response); + } + +} diff --git a/src/UpdatePostServlet.java b/src/UpdatePostServlet.java new file mode 100644 index 00000000..c9a0a313 --- /dev/null +++ b/src/UpdatePostServlet.java @@ -0,0 +1,43 @@ + + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class UpdatePostServlet + */ +@WebServlet("/UpdatePostServlet") +public class UpdatePostServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public UpdatePostServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + RequestDispatcher reqDis = request.getRequestDispatcher("update.jsp"); + reqDis.forward(request, response); + } + +} diff --git a/src/UpdateUserServlet.java b/src/UpdateUserServlet.java new file mode 100644 index 00000000..b5d2c38e --- /dev/null +++ b/src/UpdateUserServlet.java @@ -0,0 +1,43 @@ + + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class UpdatePostServlet + */ +@WebServlet("/UpdateUserServlet") +public class UpdateUserServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public UpdateUserServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + RequestDispatcher reqDis = request.getRequestDispatcher("updateuser.jsp"); + reqDis.forward(request, response); + } + +} diff --git a/src/com/test/Test.java b/src/com/test/Test.java new file mode 100644 index 00000000..c37ac320 --- /dev/null +++ b/src/com/test/Test.java @@ -0,0 +1,26 @@ +package com.test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; + +public class Test { + + public Test() { + + } + + public static void main(String[] args) throws Exception{ + Statement stmt; + ResultSet rs; + Class.forName("com.mysql.jdbc.Driver"); + Connection con; + con = DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + stmt = con.createStatement(); + rs = stmt.executeQuery("SELECT * FROM post"); + while(rs.next()){ + System.out.println(rs.getString("tittle")); + } + } +} diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF new file mode 100644 index 00000000..59499bce --- /dev/null +++ b/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/conf/commentHandler.java b/src/conf/commentHandler.java new file mode 100644 index 00000000..f9481b06 --- /dev/null +++ b/src/conf/commentHandler.java @@ -0,0 +1,29 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author Riady + */ + +import com.mysql.jdbc.Connection; +import com.mysql.jdbc.Statement; +import java.io.IOException; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.SessionScoped; +import javax.faces.context.FacesContext; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@ManagedBean(name = "commentHandler",eager=true) +@SessionScoped +public class commentHandler { + +} diff --git a/src/fileBean.java b/src/fileBean.java new file mode 100644 index 00000000..b13560a1 --- /dev/null +++ b/src/fileBean.java @@ -0,0 +1,55 @@ + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.RequestScoped; +import javax.faces.bean.SessionScoped; +import javax.servlet.http.Part; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author Riady + */ +@ManagedBean(name = "filebean",eager=true) +@RequestScoped +public class fileBean { + private Part file; + + + public fileBean(){ + + } + + public Part getFile(){ + return file; + } + + public void setFile(Part newfile){ + file=newfile; + } + + public void uploadFile() throws IOException{ + InputStream fileContent = file.getInputStream(); + File uploads = new File("/path"); + File file2 = new File(uploads, getFilename(file)); + Files.copy(fileContent,file2.toPath()); + } + + private static String getFilename(Part part) { + for (String cd : part.getHeader("content-disposition").split(";")) { + if (cd.trim().startsWith("filename")) { + String filename = cd.substring(cd.indexOf('=') + 1).trim().replace("\"", ""); + return filename.substring(filename.lastIndexOf('/') + 1).substring(filename.lastIndexOf('\\') + 1); // MSIE fix. + } + } + return null; +} +} diff --git a/src/publishServlet.java b/src/publishServlet.java new file mode 100644 index 00000000..3a65a97d --- /dev/null +++ b/src/publishServlet.java @@ -0,0 +1,89 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +import com.mysql.jdbc.Connection; +import com.mysql.jdbc.PreparedStatement; +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.DriverManager; +import java.util.Random; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * @author Riady + */ +public class publishServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException + { + Connection conn; + PreparedStatement pState; + Random random = new Random(); + PrintWriter out = response.getWriter(); + try { + Class.forName("com.mysql.jdbc.Driver"); + int updateQuery = 0; + conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/wbd_db", "root", ""); + pState = (PreparedStatement) conn.prepareStatement("UPDATE post SET status = 'published' WHERE post_id = ?"); + pState.setString(1, String.valueOf(request.getParameter("postId"))); + updateQuery = pState.executeUpdate(); + } catch(Exception e){out.println("Error" + e);} + response.sendRedirect("faces/index.jsp"); + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException + { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException + { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +}