In Spring 3.0 annotations allow you to specify the blog post method as a url. But prior to that version of Spring, is this the best way to achieve it:
@SuppressWarnings("unchecked")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse arg1) throws Exception {
ModelAndView mav = handleRequestInternal(request, arg1);
if (!Utils.loggedIn(request, arg1)) {
return new ModelAndView(new RedirectView("login.html"));
}
String id = Utils.getLoggedInUserId(request);
Key objectkey = KeyFactory.createKey(Admin.class.getSimpleName(), id);
//Admin user = userService.getAdmin(objectkey);
//System.out.println("admin key "+user.getId());
if (request.getMethod().equalsIgnoreCase("post")) {
String title = request.getParameter("title");
String content = request.getParameter("content");
if (!title.isEmpty()&&!content.isEmpty()) {
BlogPost post = new BlogPost();
post.setTitle(title);
post.setContent(new Text(content));
post.setDate(new Date());
post.setUser(objectkey);
postService.storePost(post);
}
}
return new ModelAndView(new RedirectView("news.html"));
}