Package org.springframework.web.servlet

Examples of org.springframework.web.servlet.ModelAndView


                reverseName = InetAddress.getByName(theIP).getCanonicalHostName();
            } catch (UnknownHostException e) {
                logger.error("could not run a DNS query on "+theIP);
            }
        }
        return new ModelAndView(getViewName(), "result", lines).
                addObject("timeout", Boolean.valueOf(timeout)).
                addObject("whoisServer", wh != null ? wh.getServer() + ":"+ wh.getPort() : defaultServer + ":" + defaultPort).
                addObject("domainName", reverseName);
    }
View Full Code Here


    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String originalURI = (String) request.getAttribute("javax.servlet.error.request_uri");
        if (originalURI != null && originalURI.endsWith(ajaxExtension)) {
            return new ModelAndView(ajaxViewName);
        } else {
            return new ModelAndView(viewName);
        }
    }
View Full Code Here

            if (contextName != null) {
                request.setAttribute("errorMessage",
                        getMessageSourceAccessor().getMessage("probe.src.contextDoesntExist", new Object[] {contextName}));
            }

            return new ModelAndView("errors/paramerror");
        }
    }
View Full Code Here

        } else {
            Runtime.getRuntime().gc();
            logger.debug("Advised Garbage Collection");
        }
        logger.debug("Redirected to "+redirectURL);
        return new ModelAndView(new RedirectView(redirectURL));
    }
View Full Code Here

    public void setCollectionPeriod(long collectionPeriod) {
        this.collectionPeriod = collectionPeriod;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        return new ModelAndView(getViewName())
                .addObject("pools", getJvmMemoryInfoAccessorBean().getPools())
                .addObject("collectionPeriod", new Long(getCollectionPeriod()));
    }
View Full Code Here

        String path = request.getServletPath();
        String internalPath = path.replaceAll(xmlMarker, "");

        Controller controller = (Controller) getApplicationContext().getBean(internalPath);
        if (controller != null) {
                ModelAndView modelAndView = controller.handleRequest(request, response);
                if (modelAndView.getModel() != null) {
                    TransportableModel tm = new TransportableModel();
                    tm.putAll(modelAndView.getModel());
                    XStream x = new XStream();
                    x.toXML(tm, response.getWriter());
                }
        }
        return null;
View Full Code Here

        boolean supportsGlobal = getContainerWrapper().getResourceResolver().supportsGlobalResources();
        boolean supportsPrivate = getContainerWrapper().getResourceResolver().supportsPrivateResources();
        boolean supportsDSLookup = getContainerWrapper().getResourceResolver().supportsDataSourceLookup();
        List privateResources = getContainerWrapper().getPrivateDataSources();
        List globalResources = getContainerWrapper().getGlobalDataSources();
        return new ModelAndView(getViewName())
                .addObject("supportsGlobal", Boolean.valueOf(supportsGlobal))
                .addObject("supportsPrivate", Boolean.valueOf(supportsPrivate))
                .addObject("supportsDSLookup", Boolean.valueOf(supportsDSLookup))
                .addObject("privateResources", privateResources)
                .addObject("globalResources", globalResources);
View Full Code Here

* @author Vlad Ilyushchenko
*/
public class ListApplicationResourcesController extends ContextHandlerController {

    protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception {
        return new ModelAndView(getViewName(), "resources", getContainerWrapper().getResourceResolver().getApplicationResources(context));
    }
View Full Code Here

                if (e instanceof ThreadDeath) {
                    throw (ThreadDeath) e;
                }
            }
        }
        return new ModelAndView(getViewName(), "available",
                Boolean.valueOf(context != null && context.getAvailable()));
    }
View Full Code Here

        String sql = ServletRequestUtils.getStringParameter(request, "sql", null);

        if (sql == null || sql.equals("") || sql.trim().equals("")) {
            request.setAttribute("errorMessage", getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.required"));

            return new ModelAndView(getViewName());
        }

        int maxRows = ServletRequestUtils.getIntParameter(request, "maxRows", 0);
        int rowsPerPage = ServletRequestUtils.getIntParameter(request, "rowsPerPage", 0);
        int historySize = ServletRequestUtils.getIntParameter(request, "historySize", 0);

        // store current option values and query history in a session attribute

        HttpSession sess = request.getSession();
        DataSourceTestInfo sessData = (DataSourceTestInfo) sess.getAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR);

        synchronized(sess) {
            if (sessData == null) {
                sessData = new DataSourceTestInfo();
                sess.setAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR, sessData);
            }

            sessData.setMaxRows(maxRows);
            sessData.setRowsPerPage(rowsPerPage);
            sessData.setHistorySize(historySize);
            sessData.addQueryToHistory(sql);
        }

        DataSource dataSource = null;

        try {
            dataSource = getContainerWrapper().getResourceResolver().lookupDataSource(context, resourceName);
        } catch (NamingException e) {
            request.setAttribute("errorMessage", getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[]{resourceName}));
        }

        if (dataSource == null) {
            request.setAttribute("errorMessage", getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[]{resourceName}));
        } else {
            List results = null;
            int rowsAffected = 0;

            try {
                // TODO: use Spring's jdbc template?
                Connection conn = dataSource.getConnection();

                try {
                    conn.setAutoCommit(true);
                    PreparedStatement stmt = conn.prepareStatement(sql);

                    try {
                        boolean hasResultSet = stmt.execute();

                        if (! hasResultSet) {
                            rowsAffected = stmt.getUpdateCount();
                        } else {
                            results = new ArrayList();
                            ResultSet rs = stmt.getResultSet();

                            try {
                                ResultSetMetaData metaData = rs.getMetaData();

                                while(rs.next() && (maxRows < 0 || results.size() < maxRows)) {
                                    Map record = new LinkedHashMap();

                                    for (int i = 1; i <= metaData.getColumnCount(); i++) {
                                        String value = rs.getString(i);

                                        if (rs.wasNull()) {
                                            value = getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.null");
                                        } else {
                                            value = HtmlUtils.htmlEscape(value);
                                        }

                                        // a work around for IE browsers bug of not displaying
                                        // a border around an empty table column

                                        if (value.equals("")) {
                                            value = "&nbsp;";
                                        }

                                        record.put(HtmlUtils.htmlEscape(metaData.getColumnName(i)), value);
                                    }

                                    results.add(record);
                                }
                            } finally {
                                rs.close();
                            }

                            rowsAffected = results.size();
                        }
                    } finally {
                        stmt.close();
                    }
                } finally {
                    conn.close();
                }

                // store the query results in the session attribute in order
                // to support a result set pagination feature without re-executing the query

                synchronized(sess) {
                    sessData.setResults(results);
                }

                ModelAndView mv = new ModelAndView(getViewName(), "results", results);
                mv.addObject("rowsAffected", String.valueOf(rowsAffected));
                mv.addObject("rowsPerPage", String.valueOf(rowsPerPage));

                return mv;
            } catch (SQLException e) {
                String message = getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.failure", new Object[] { e.getMessage() });
                logger.error(message, e);
                request.setAttribute("errorMessage", message);
            }
        }

        return new ModelAndView(getViewName());
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.ModelAndView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.