Solved

Add/Edit Blog using Java Servlet with static HTML

Posted on 2010-11-18
3
1,825 Views
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.
blogentry.html
Blogedit.html
0
Comment
Question by:Razultull
3 Comments
 
LVL 11

Accepted Solution

by:
Manish earned 500 total points
Comment Utility
THis is example how to write servlet ,
get the values from UI.
http://www.jsptube.com/servlet-tutorials/simple-servlet-example.html
Based on this , you can change as per your requirement.
0
 
LVL 59

Expert Comment

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now