Java 类javax.servlet.jsp.SkipPageException 实例源码

项目:ServletStudyDemo    文件:RefererTag.java   
@Override
public void doTag() throws JspException, IOException {
    // TODO Auto-generated method stub
    PageContext pageContext=(PageContext) this.getJspContext();

    HttpServletRequest request=(HttpServletRequest) pageContext.getRequest();
    HttpServletResponse response=(HttpServletResponse) pageContext.getResponse();
    //1���õ�������referer
    String referer=request.getHeader("referer");
    //2���ж������ߵ�ҳ���Dz���Ҫ����������վ
    if(referer==null || !referer.startsWith(site)){//�ǵ�����
        if(page.startsWith(request.getContextPath())){
            response.sendRedirect(page);
        }else if(page.startsWith("/")){
            response.sendRedirect(request.getContextPath()+page);
        }else{
            response.sendRedirect(request.getContextPath()+"/"+page);
        }
        //����ǵ����ߣ�jsp���µ�ҳ��Ͳ��������߲鿴
        throw new SkipPageException();
    }
}
项目:robotoy    文件:RoboToyCommonTag.java   
/**
 * Forwards to another relative page. User browser will still be pointing to the same URL as before.
 */
protected void forward(String uri) throws JspException, IOException, SkipPageException {
    PageContext context = (PageContext)this.getJspContext();
    try {
        context.forward(uri);
    } catch (ServletException e) {
        throw new JspException("Error in "+getClass().getSimpleName()+" while forwarding to "+uri,e);
    }
    throw new SkipPageException();
}
项目:robotoy    文件:RoboToyCommonTag.java   
protected GameState assertGame() throws IOException, SkipPageException {
    GameState game = getGame();
    if (game==null) {
        HttpServletResponse response = getResponse();
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ERROR_MISSING_GAME_STATE);
        throw new SkipPageException();
    }
    else {
        return game;
    }
}
项目:robotoy    文件:RoboToyCommonTag.java   
protected RoboToyServerController assertController() throws IOException, SkipPageException {
    RoboToyServerController controller = getController();
    if (controller==null) {
        HttpServletResponse response = getResponse();
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ERROR_MISSING_CONTROLLER);
        throw new SkipPageException();
    }
    else {
        return controller;
    }
}
项目:robotoy    文件:LoginPageTag.java   
private void checkForAdminUser(String userName) throws SkipPageException, IOException {
    if (userName==null)
        return;
    String adminUserName = assertController().getAdminUserName();
    if (adminUserName==null)
        return;
    if (adminUserName.equalsIgnoreCase(userName)) {
        // Should redirect admin to special page
        getResponse().sendRedirect("options.jsp");
        throw new SkipPageException();
    }
}
项目:JavaEE-WebComponents    文件:SkipPageExceptionThrowTag.java   
/**
 * This tag throw a SkipPageException to the response. What this does it to print 
 * everything on the page till that point when the tag is invoked BUT do not print
 * anything after the tag.
 */
@Override
public void doTag() throws JspException, IOException {
    getJspContext().getOut().print("Message from within SkipPageExceptionThrowTag doTag() method.<br>");
    getJspContext().getOut().print("Throwing a JSP SkipPageException.....<br>");
    try{
        int i = 10/0; //will throw Arithmatic Exception
    }catch(Exception exception){
        System.out.println(this.getClass().getName() + " : Got exception in doTag() method: " + exception.getMessage());
        //SkipPageException extends JspException
        throw new SkipPageException();
    }
}
项目:Spring-Blog-Cms    文件:DescriptionThumb.java   
@Override
public void doTag() throws JspException, IOException {
    try {
        String croppedDescription = description;
        if (description != null && description.length() > 50)
            croppedDescription = description.substring(0, 50) + " ...";
        getJspContext().getOut().write(croppedDescription);
    } catch (Exception e) {
        e.printStackTrace();
        // stop page from loading further by throwing SkipPageException
        throw new SkipPageException("Exception in cropping "
                + " with description " + description);
    }
}
项目:robotoy    文件:RoboToyCommonTag.java   
/**
 * Redirects to another page, maybe in another server. User browser will point to the new URL.
 */
protected void redirect(String url) throws JspException, IOException, SkipPageException {
    getResponse().sendRedirect(url);
    throw new SkipPageException();
}
项目:ServletStudyDemo    文件:SimpleTagDemo4.java   
@Override
public void doTag() throws JspException, IOException {
    // TODO Auto-generated method stub

    throw new SkipPageException();
}