Solved

Add/Edit Blog using Java Servlet with static HTML

Posted on 2010-11-18
3
1,846 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Accepted Solution

by:
Manish earned 500 total points
ID: 34308678
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 60

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.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.

717 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