Example usage for javax.servlet ServletException fillInStackTrace

List of usage examples for javax.servlet ServletException fillInStackTrace

Introduction

In this page you can find the example usage for javax.servlet ServletException fillInStackTrace.

Prototype

public synchronized Throwable fillInStackTrace() 

Source Link

Document

Fills in the execution stack trace.

Usage

From source file:org.osjava.atom4j.servlet.AtomServlet.java

/**
 * Create a new Entry.  The jury is still out on whether AtomAPI will
 * support the creation of more than one Entry at a time.  The API
 * does specify, however, that creating an Entry will return a 
 * Location header containing the Atom URL to that Entry.  For now
 * Atom4J is returning the address of the <b>last</b> Entry created.
 * //w w  w.jav  a  2  s.c o  m
 * PathInfo: /USER/entry
 * 
 * @param request
 */
protected void postEntry(String[] pathInfo, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    Collection entries = null;
    // is this a <feed> wrapped around several <entry>'s ?
    FeedReader feedReader = new FeedReader(request.getInputStream());
    if (feedReader.getFeed() != null) {
        entries = feedReader.getFeed().getEntries();
    } else {
        // or is it really just one Entry?
        EntryReader reader = new EntryReader(request.getInputStream());
        entries = reader.getEntries();
    }
    if (entries == null || entries.size() < 1) {
        error(request, response, "No Entry Found", "No entry was found in the supplied information.");
        return;
    }

    Entry entry = null;
    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
        entry = (Entry) iter.next();
        try {
            saveNewEntry(entry);
        } catch (Exception e) {
            ServletException se = new ServletException(e);
            se.fillInStackTrace();
            throw se;
        }
    }

    if (entry != null) {
        String entryLoc = new StringBuffer(baseURL).append("/atom/").append(pathInfo[0]).append("/entry/")
                .append(entry.getId()).toString();
        response.setHeader("Location", entryLoc);
        //response.setStatus( HttpServletResponse.SC_CREATED ); 
        response.setStatus(HttpServletResponse.SC_SEE_OTHER);
    }
}