Author: agilliland
Date: Thu Jan 26 22:58:42 2006
New Revision: 372770
URL: http://svn.apache.org/viewcvs?rev=372770&view=rev
Log:
better handling for the case when the weblog entry is null, so we don't print a
long stacktrace.
Modified:
incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java
Modified:
incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java?rev=372770&r1=372769&r2=372770&view=diff
==============================================================================
---
incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java
(original)
+++
incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java
Thu Jan 26 22:58:42 2006
@@ -112,10 +112,8 @@
* Here we handle incoming comment postings. We will collect the data,
* validate it, and save it.
*/
- public void doPost(
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
+ public void doPost(HttpServletRequest request, HttpServletResponse
response)
+ throws IOException, ServletException {
boolean preview = false;
String error = null;
@@ -128,16 +126,21 @@
else if (method.equals("preview"))
preview = true;
+ // parse request and validate
RollerRequest rreq = RollerRequest.getRollerRequest(request);
HttpSession session = request.getSession();
- try {
- // Get weblog entry object
- WeblogEntryData entry = rreq.getWeblogEntry();
- if (entry == null || entry.getId() == null) {
- throw new RollerException("Unable to find WeblogEntry for "+
- request.getParameter(RollerRequest.WEBLOGENTRYID_KEY));
- }
+
+ // make sure we know the entry this comment is going to
+ WeblogEntryData entry = rreq.getWeblogEntry();
+ if (entry == null || entry.getId() == null) {
+ session.setAttribute(RollerSession.ERROR_MESSAGE, "Cannot post
comment to null entry");
+ RequestDispatcher dispatcher =
+ request.getRequestDispatcher(entry_permalink);
+ dispatcher.forward(request, response);
+ return;
+ }
+ try {
// we know what our weblog entry is, so setup our permalink url
entry_permalink = entry.getPermaLink();