Add/Edit Blog using Java Servlet with static HTML

Posted on 2010-11-18
Last Modified: 2013-11-24
Hey so i'm trying to create a blog site which is fully implemented in java servlets. I am currently on the Add/Edit blog entry part and having a bit of trouble figuring out how to go about it. My knowledge of java is limited but i am fairly fluent with HTML/CSS/XHTML.

The AddEntry servlet is responsible for adding a post entry to the blog. It is primarily accessible from the form defined in a newpost.html file. AddEntry will receive parameters from the newpost form (using the POST method) indicating the title of blog post and text of the blog post. Use the session object to determine if the user is logged in. If not,redirect to the login.html file;otherwise make the the post has a non-empty title and text.      If the data is valid, create a new Entry object and then call DataStore.addEntry to serialize the object to disk and redirect to View. If any of the data is invalid generate an error page indicating the problem and a link back to the AddEntry servlet.

The Edit Entry on the other hand is responsible for editing an existing post entry on the blog. If this servlet receives a GET request it will have a single parameter that is the entryId. Use the entryId to call DataStore.getEntry to retrieve the Entry object with the corresponding id. If DataStore.getEntry returns null it means an entry with that id does not exist. In this case, generate an error response to the client with a link back to the View. Otherwise,generate a form that looks like the AddEntry form except it has the title and text of the blog post pre-filled in the forms text input and text area fields. The generated form has the method set to POST and the action is set to point to the editentry servlet. In addition, make sure the submit button for this form has as its value the entryId of the blog entry (you will need this when the user submits the edits).
If the servlet receives a POST request it will receive two parameters (like to the AddEntry servlet) for the title and text of the blog post and a third parameter (with a name of your choice) for the submit button whose value is the entryId. Use the entryId to look up the Entry object for this blog post using DataStore.getEntry and then update this object with the new information. Save the entr using DataStore.update Entry.

I have static HTML files for all these pages, but i would like to know how to actually implement it with these pages.

I have attached the html files, and while this is a project for myself it is also in part an assignment.
I understand this is a lot to ask but i hope i have made myself clear. I will be eternally grateful if you could help me out on this one. I am new to this site, and i definitely intend to be staying.
Question by:Razultull
LVL 11

Accepted Solution

Manish earned 500 total points
ID: 34308678
THis is example how to write servlet ,
get the values from UI.
Based on this , you can change as per your requirement.
LVL 59

Expert Comment

by:Kevin Cross
ID: 36929522
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
array6 challenfge 6 114
strCount chalenge 3 87
word0 challenge 3 100
mysql jsp example issue 32 48
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question