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.