Exception vs. redirecting to an errorpage

When should I throw an exception to the server and when shold I redirect the user to an error page?
Is there a clear distinction for when to use either of them?
/Niklas Andersson
Sweden

I seem to recall seeing an ad on TV about the upcoming (made for TV?) movie "Helen of Troy," over which a mythical war was fought. I dare say I'd rather fight to a bloody death for (fill in whatever your imagination wants) with Helen (or at least the actress playing her role) than face the religious conflict this Easter Sunday that answering such questions often engenders.
That said, my personal opinion is that you should throw exceptions, rather than redirect.
If you are using JSPs, the errorPage directive will dispatch (rather than redirect) to an error page JSP, conveniently filling in the variable 'exception' with whatever Exception you threw. At that point, you can display some sanitized message to a user, log the event to stderr (with a stack trace), use the JavaMail API to page your cell phone at 3 a.m. to alert you to the impending disaster on your site, etc. etc. etc. When I'm debugging, I even print the stack trace in an HTML comment block on the error page, so I can easily see what happened, without corrupting the "user friendly" graphics, blandly denying to our users that NullPointerExceptions are anything but planned routine maintenance, for which we sincerely apolgize.
When you redirect, you lose all this, and you lose the exception itself, so you have no clue what went wrong, unless you include code in each and every catch block in your entire system, to write the trace to some kind of log. The one you skip will invariably, it seems, be the place where the most exceptions end up getting caught.
Okay, now I'll let some zealot with an opposing point of view weigh in, after which you'll be right back where you started.
Cheers!
Jerry Oberle
perl -e 'printf "mailto%cg%s%cearthlink%cnet\n", 58, "oberle", 64, 46;'

Similar Messages

  • Exception on redirect page, I got that code from Balusc

    Hi,
    I followed balusc sir code for "PRG", here in that code exactly on the redirect instruction I am getting illegalstate exception. I just applied on a test project. It doesn't have complex code, only one page, backing bean and phaselistner class. I got the below trace on valuechange event
    WARNING: phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@bf711e) threw exception: java.lang.IllegalStateException null
    org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:435)
    com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:419)
    bean.LifeCycleListener.redirect(LifeCycleListener.java:124)
    bean.LifeCycleListener.beforePhase(LifeCycleListener.java:67)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:619)

    U will need to have the fone flashed to open it back up to use ure unlock code again
    Nokia Lumia 520
     iphone 6 Plus.
    Be happy !!

  • Exceptions .. redirecting System.err

    I've redirected System.err to a custom class that extends OutputStream.
    I have a couple of questions which someone in here might know the answer to:
    1. When I receive an exception write(byte b[], int off, int len) is called. The array of bytes is always 8192 long - padded with \x0000 at the end. Why?
    2. How do I know an exception has ended? I want to notify the user when it has ended (with a popup). But write() is called for each line, and flush() doesn't seem to be called at all.
    Best regards,
    Bjorn

    Depends what kind of a program you are writing. If you are doing a standalone application, you can always have a master try-catch block in the main() method that will catch Throwable. Nothing should make it past that.
    Now, if you are doing a servlet or EJB, you don't want to trap every exception because the container is supposed to receive and handle them for you (thread death, out of memory, etc.) If you have a front-controller pattern implemented, you can put a master try-catch block there and do something like the following:
    try {
    // implement cool functionality here
    catch (RuntimeException e) {
    // use code to retrieve stack trace
    throw e;
    catch (Exception e) {
    // use code to retrieve stack trace
    // handle exception in application-specific manner
    catch (Error e) {
    // use code to retrieve stack trace
    throw e;
    The cool "feature" about exceptions is that they propogate. So, if you don't have the appropriate catch block, it will move to the previous caller. Hence, you can have a master exception processor if either a) you re-throw exceptions on to be procsesed by the master exception processor or b) you don't handle the exception at all and let it propogate naturally.
    You also have a number of options so you don't have to rewrite 300 exception try-catch blocks. Subclass Exception, and for all your custom exceptions, put the functionality to dump or store the stack trace there. It will happen anytime your custom exception is instantiated.
    Lots of ways to skin a digital cat. However, the argument that you will have to change code to get new functionality is part and parcel of the beast. If you want to capture the stack trace and do something with it, code somewhere will have to change. Either use inheritance, delegation or the exception propogation mechanism inherent to Java to minimize your work.
    - Saish
    "My karma ran over your dogma." - Anon

  • Exception when redirect page

    Hi
    I create a class implements PhaseListener
    In afterPhase method I use FacesContext of ADF for redirect page as follow:
    public void afterPhase(PhaseEvent phaseEvent) {
    PhaseId phaseId = phaseEvent.getPhaseId();
    FacesContext facesContext = phaseEvent.getFacesContext();
    String url = ....;
    try {
    facesContext.getExternalContext().redirect(url);
    } catch (IOException ioe) {
    But I see "java.lang.IllegalStateException: Response already committed"
    I do not know why?
    Please help me

    Hi,
    You can try this code instead of facesContext.getExternalContext().redirect(url);
    HttpServletResponse response = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
    response.sendRedirect(url);
    FacesContext.getCurrentInstance().responseComplete();Hope this helps
    Joseba

  • If there is an error in jsp, will it be redirected or included to errorpage

    If we give errorpage attribute in page directive, and if any runtime error occurs in the jsp page, will it be redirected, forwarded to errorpage or errorpage will be included here?
    Thanks
    m_nekkanti

    definitely NOT redirected.
    If the response has not been committed as yet, then it should do a forward (ie cancel output to date, and just display error page)
    Else if the page has been committed (flushed, or has overrun buffer) then does an includes the error page rather than forwarding.
    Basically, something like this:
    try{
       getRequestDispatcher("/error.jsp").forward(request, response)
    catch (IllegalStateException e){
      // if we cannot forward, then include the error page.
      getRequestDispatcher("/error.jsp").include(request, response);
    }

  • Page flow exception

    I have one serious problem when handling exception in page flow. ie.
    my code looks like,
    // Generated by WebLogic Workshop
    // Created on: Mon Dec 01 15:31:45 GMT+05:30 2003
    // By: kshashishekar
    package portlets.validation.validation;
    import com.bea.wlw.netui.pageflow.FormData;
    import com.bea.wlw.netui.pageflow.Forward;
    import com.bea.wlw.netui.pageflow.PageFlowController;
    import com.bea.wlw.netui.tags.html.TreeNode;
    import javax.security.auth.login.FailedLoginException;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.*;
    import com.login.CustomLogin;
    import com.bea.p13n.controls.login.UserLoginControl;
    * @jpf:controller struts-merge="struts-config-portlets-validation-validation2.xml"
    * @jpf:message-resources resources="validation.validator.Message"
    * @jpf:view-properties view-properties::
    * <!-- This data is auto-generated. Hand-editing this section is not recommended.
    -->
    * <view-properties>
    * <pageflow-object id="pageflow:/portlets/validation/validation/validationController.jpf"/>
    * <pageflow-object id="action:begin.do">
    * <property value="280" name="x"/>
    * <property value="60" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="action:validate1.do#portlets.validation.validation.validationController.ValidateForm">
    * <property value="220" name="x"/>
    * <property value="200" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="action:logout.do#portlets.validation.validation.validationController.ValidateForm">
    * <property value="120" name="x"/>
    * <property value="100" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="action-call:@page:validate1Page1.jsp@#@action:validate1.do#portlets.validation.validation.validationController.ValidateForm@">
    * <property value="384,320,320,256" name="elbowsX"/>
    * <property value="172,172,192,192" name="elbowsY"/>
    * <property value="West_1" name="fromPort"/>
    * <property value="East_1" name="toPort"/>
    * </pageflow-object>
    * <pageflow-object id="page:validate1Page1.jsp">
    * <property value="420" name="x"/>
    * <property value="180" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="action-call:@page:Result.jsp@#@action:validate1.do#portlets.validation.validation.validationController.ValidateForm@">
    * <property value="156,170,170,184" name="elbowsX"/>
    * <property value="332,332,203,203" name="elbowsY"/>
    * <property value="East_1" name="fromPort"/>
    * <property value="West_2" name="toPort"/>
    * </pageflow-object>
    * <pageflow-object id="page:Result.jsp">
    * <property value="120" name="x"/>
    * <property value="340" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="page:/error.jsp">
    * <property value="40" name="x"/>
    * <property value="180" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="forward:path#success#validate1Page1.jsp#@action:begin.do@">
    * <property value="316,350,350,384" name="elbowsX"/>
    * <property value="52,52,172,172" name="elbowsY"/>
    * <property value="East_1" name="fromPort"/>
    * <property value="West_1" name="toPort"/>
    * <property value="success" name="label"/>
    * </pageflow-object>
    * <pageflow-object id="forward:path#success#Result.jsp#@action:validate1.do#portlets.validation.validation.validationController.ValidateForm@">
    * <property value="184,170,170,156" name="elbowsX"/>
    * <property value="192,192,332,332" name="elbowsY"/>
    * <property value="West_1" name="fromPort"/>
    * <property value="East_1" name="toPort"/>
    * <property value="success" name="label"/>
    * </pageflow-object>
    * <pageflow-object id="forward:path#success#validate1Page1.jsp#@action:logout.do#portlets.validation.validation.validationController.ValidateForm@">
    * <property value="156,270,270,384" name="elbowsX"/>
    * <property value="92,92,172,172" name="elbowsY"/>
    * <property value="East_1" name="fromPort"/>
    * <property value="West_1" name="toPort"/>
    * <property value="success" name="label"/>
    * </pageflow-object>
    * <pageflow-object id="control:com.bea.p13n.controls.login.UserLoginControl#myControl">
    * <property value="28" name="x"/>
    * <property value="34" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="formbeanprop:portlets.validation.validation.validationController.ValidateForm#username#java.lang.String"/>
    * <pageflow-object id="formbeanprop:portlets.validation.validation.validationController.ValidateForm#password#java.lang.String"/>
    * <pageflow-object id="formbean:portlets.validation.validation.validationController.ValidateForm"/>
    * </view-properties>
    public class validationController extends PageFlowController
    * This is the control used to generate this pageflow
    * @common:control
    private UserLoginControl myControl;
    // Uncomment this declaration to access Global.app.
    // protected global.Global globalApp;
    // For an example of page flow exception handling see the example "catch"
    and "exception-handler"
    // annotations in {project}/WEB-INF/src/global/Global.app
    * This method represents the point of entry into the pageflow
    * @jpf:action
    * @jpf:forward name="success" path="validate1Page1.jsp"
    protected Forward begin()
    return new Forward( "success" );
    * @jpf:action validation-error-page="validate1Page1.jsp"
    * @jpf:forward name="success" path="Result.jsp"
    * @jpf:catch method="exceptionHandler" type="Exception"
    protected Forward validate1(ValidateForm aForm) throws Exception
    com.bea.p13n.usermgmt.profile.ProfileWrapper var = myControl.login( aForm.username,
    aForm.password, getRequest());
    getRequest().setAttribute( "results", var );
    return new Forward("success",aForm);
    * Action encapsulating the control method :logout
    * @jpf:action
    * @jpf:forward name="success" path="validate1Page1.jsp"
    * @jpf:catch message="not authenticated" path="/error.jsp" type="Exception"
    public Forward logout( ValidateForm aForm )
    throws Exception
    myControl.logout( getRequest() );
    return new Forward( "success" );
    * @jpf:exception-handler
    * @jpf:forward name="errorPage" path="/error.jsp"
    protected Forward exceptionHandler( Exception ex, String actionName, String
    message, FormData form )
    String displayMessage = "An exception occurred in the action " + actionName;
    System.out.println ("display message "+displayMessage);
    getRequest().setAttribute( "errorMessage", displayMessage );
    return new Forward( "errorPage" );
    * FormData get and set methods may be overwritten by the Form Bean editor.
    public static class ValidateForm extends org.apache.struts.validator.ValidatorForm
    private String password;
    private String username;
    public void setUsername(String username)
    this.username = username;
    public String getUsername()
    return this.username;
    public void setPassword(String password)
    this.password = password;
    public String getPassword()
    return this.password;
    * added just to test validate (override) method.
    public ActionErrors validate(ActionMapping map, HttpServletRequest req)
    ActionErrors errors = null;
    try {
    errors = super.validate(map,req);
    }catch (Exception e)
    e.printStackTrace();
    if (errors ==null) {
    System.out.println ("errors = "+errors);
    } else
    System.out.println ("errors= "+errors);
    return errors;
    in the above code when we call "validate1" action, it will authenticate successfully
    when we enter valid username and passowrd.
    But when i enter invalid credentials page flow controller should execute "handleException"
    method but at this time i am getting an error
    Page Flow Unhandled Exception
    Exception: java.lang.IllegalArgumentException
    Message: argument type mismatch
    A java.lang.IllegalArgumentException exception was thrown and not handled by any
    Page Flow. See the console for the exception stack trace.
    please help us on how to rectify this error.
    thanks,
    shashi
    [validationController.jpf]

    Hi-
    That may be on the right track, but the /index.jsp page gets displayed in the
    portlet...I am still within the portal framework, so I don't think I am loosing
    the context...
    -Howie
    "Khurram Zafar" <[email protected]> wrote:
    >
    you are most likely redirecting to the /error.jsp page and losing the
    context for
    your portal app. The index.jsp page may be defined as your <welcome-file>
    in your
    web.xml file. The best thing to do is to save the context before visiting
    error.jsp
    and then provide a link in error.jsp to go back. Look at javadoc for
    PageURL for
    obtaining the URL to a portal page, you can then save it in session of
    pass it
    to your error page.
    "Howie Oakes" <[email protected]> wrote:
    Hello-
    I have a page flow portlet that I am testing some exception handling
    on. Right
    now when I catch an exception, I display the global /error.jsp page,
    using the
    @jpf:catch tag. The problem is when I refresh the page after viewing
    the error
    page, the pageflow always pulls up the /index.jsp page at the root of
    the webapp.
    I have to get a new session to see the original page flow.
    This only happens when I am running the Jpf as a portlet...I don't see
    this behavior
    with it stand-alone.
    I am not sure why the index.jsp page is being called...there are noreferences
    to it in my jpf code...
    thanks,
    Howie

  • Catching an exception within a JSP

    Hi all,
    I need to catch an exception in a JSP before the errorPage handles it. Have tried with try-catch but it seems like the exception is thrown to the errorPage anyway. Do you know of any technique to handle this.
    In other words: I would like to specify program logic for one exception within the JSP itself. Let us say Customer.Authenticate() throws an Exception when the given e-mail is not included in customer-DB. I would like to append logic instead of being redirected to errorPage.
    Anyone done this, can it even be done?
    ,Chr

    I would try keeping the error page as it is and still adding the logic in the catch block. If that does not help, then remove the error page and use <jsp:forward> (after your logic) in the catch block to explicitly go to the error page.
    or if you want to process that logic anyways in case of an exception, try adding your logic in the finally block.

  • Catching exceptions in a declarative way....

    Hi all,
    I'd like to catch my exceptions as declared in my web.xml file
    <error-page>
    <exception-type>javax.servlet.ServletException</exception-type>
    <location>/error.jsp</location>
    </error-page>
    the problem is that this approach doesn't work with servlets:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    throw new javax.servlet.ServletException("errore");
    this doesn't redirect to error.jsp, but it simply crashes the navigation with the stack trace.
    On the other hand with JSP...
    <%
    throw new javax.servlet.ServletException("errore da jsp");
    %>
    it works. I'm using Tomcat 4.1 container.
    Any help ???
    Thanks
    Francesco

    hey,
    i am not usre if u can do that.. but a better a way to handle exception and redirect to an error page is.. in every jsp/ or servlet generated page add
    <%@ page errorPage="errorpage.htm"%>
    So when ever an error or exception is encounterd the error page is automatically opened. in this case errorpage.htm is opened ..
    hope this will help u ..

  • Use subflow or redirect step when calling another script

    I have a main AA script and it calls another script when caller press option 6.  When a caller presss 6 it is only transferring the call to the sub script.  it does not return any values to the main script.
    In this situation, is it better to use subflow or redirect step.  i am think redirect step but just want to check with the user community.
    thanks in advance.

    Either will work. Here are a few thoughts to consider in no particular order:
    Subflows count toward the originally triggered scripts' maximum step count. If you have a lot of steps, this may result in an exception. Redirecting the call restarts this counter since the newly triggered script will have its own counter.
    NOTE: You might think that this is exactly why the Trigger Application step in Synchronous mode was created for. Alas, there is a bug which renders this useless in 7.0(1): CSCtd72562
    Redirecting the call will result in the user hearing ringback. This would occur because of the recommended two-second delay step following the Accept step of a step to prevent a race condition. I find this to be irritating enough to shy away from it mid-way through an IVR if possible.
    Subflows are more difficult to debug. You need to have sufficient code embedded in them such that you can trigger and reactively debug them.
    Be sure that the redirect destination of an actual CCX Trigger (CTI Route Point). Do not set it to a value in UCM that is translated or forwarded back to CCX. This results in a race condition which CCX does not handle well.
    If you were asking me as an individual my answer would be this: Is the code small enough and not reused elsewhere? If yes, then put it in the first script and avoid this topic all together. If it's reused in a bunch of places from multiple scripts and does not represent a large quantity of steps: use a subflow. Otherwise use Trigger Application if you're on a new enough version or Call Redirect if you're not.

  • How to redirect to an error page when database is down

    We have build an struts/jsp-application with JDeveloper 10g and ADF. If the connection to the database fails, we get a plain page with header "500 Internal Server Error" and the exception and a stack trace. Of course we want to catch this exception and redirect the user to an error page with all of the standard design elements of our site and with a textual description of the error of our one choice.
    Our attempts to solve this includes adding error-page tags with error-code and exception-type:
    <error-page>
    <exception-type>javax.servlet.jsp.JspTagException</exception-type>
    <location>error.jsp</location>
    </error-page>
    <error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>error.jsp</location>
    </error-page>
    <error-page>
    <exception-type>oracle.jbo.JboException</exception-type>
    <location>error.jsp</location>
    </error-page>
    <error-page>
    <exception-type>oracle.jbo.DMLException</exception-type>
    <location>error.jsp</location>
    </error-page>
    <error-page>
    <exception-type>java.sql.SQLException</exception-type>
    <location>error.jsp</location>
    </error-page>
    <error-page>
    <error-code>500</error-code>
    <location>error.jsp</location>
    </error-page>
    Are there other ways to do this, or are there things we have forgotten to do, that has to be done for this solution to work.
    We have also tried try and catch in a variety of the lifecycle methods in the DataAction subclass for the page, but none of these are ever called. It seems the error happens before the first lifecyle method starts. We can't figure out where to catch this exception.
    In other cases the web.xml mechanism seems to work.

    Try the Global Exception Mechanism within Struts...

  • Does using self-signed cert. on ISE server has anthing to do with url redirect being not working

    Hi,
    I am setting up wired ISE environment. Everything is going fine, except url redirect is not working.
    I just wondering, if using self-signed certificate on ISE server has anothing to do with the problem ?.
    Appreciate your input.
    Thanks

    Hi,
    As long as you have not changed the hostname or the domain name (and dns is accurate). You should only receive the certificate warning but still get redirected without any issues.
    Thanks,
    Tarik Admani
    *Please rate helpful posts*

  • How to make redirects work with NSAPI plug-in

    We have a NSAPI plug-in on a Iplanet server which routes any URL request with "weblogic"
    on it to a WebLogic server with a PathTrim. eg. http://ksopsd01/weblogic/myapp/login.jsp.
    All my forwards are working fine except any redirection. My redirects fails
    as it does not have the "weblogic" in it. Is there anyting like PathPrepend to
    get my redirects working? Or do I need to hardcode "weblogic" in all my redirections.
    Any help would be very much appreciated.
    Thanks

    Hello Globalmark
    For your problem dealing only with Skype, Skype supports their product with a comprehensive Help system for answers to your Skype-specific questions.
    If you cannot find the answer you need from their Knowledgebase, Troubleshooter, User Guides, or dedicated Skype-user forum, you can get technical support directly from Skype.
    MSN (now Microsoft) Messenger for Mac cannot use ANY camera unless you are using the "corporate" version. The personal version is a text only app.
    This post will give you the options available to you for using your MacBook Pro to contact those whose only chat client application is MSN (now Microsoft) Messenger.
    Your posted system info shows that you are still using Mac OS X (10.5.1). If that is correct, you may want to consider the advantages of updating to the latest version of Leopard.
    EZ Jim
    PowerBook 1.67 GHz w/Mac OS X (10.4.11) G5 DP 1.8 w/Mac OS X (10.5.2)  External iSight

  • Error page, catching Exception

    Hello.
    When my page throws Exception, i redirect it to error page.
    I have this code in web.xml:
       <error-page>
          <exception-type>java.lang.Exception</exception-type>
          <location>/error.jsp</location>
       </error-page>      Everything is ok.
    But i want to write this exception to my log. I want do this in error page.
    So my question is:
    how can I get this exception on error page?

    Jsp' directive in /error.jsp
    <%@page isErrorPage="true" %>
    then variable "exeption" is availible in jsp, like this
    <%
    StackTraceElement[] st = exception.getStackTrace();
    %>

  • Trouble with Login Redirect [$_SESSION['PrevUrl']

    I'm using the DW functionality to confirm that a user is logged in before allowing access to a page. Everything works except successfully redirecting to the previous URL. Here's the situation:
    User accesses a page with a url such as "addtocookbook.php?recipeid=6".
    Since the user is not logged in, they are redirected to"login.php".
    After successfully logging in, the user is redirected to "addtocookbook.php" without the "recipe=6".
    My login page does attempt to direct the user to the previous url (if it exists). I'm not sure if there is a simple way to make the variable $_SESSION['PrevUrl'], used by DW to redirect,  store the entire url.
    Any help is appreciated.
    Elie Chocron

    The problem lies with some obsolete code in the Restrict access to page server behavior. Fortunately, the fix is quite simple.
    The affected section of code is as follows:
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
      $MM_referrer .= "?" . $QUERY_STRING;
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo);
      exit;
    All that is necessary is to replace the three instances of $QUERY_STRING like this:
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
      $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo);
      exit;
    The redirect will then work correctly.

  • Unable to catch the exceptions caused by '|', '"' and '~' symbol in the URL

    I have a VB.net website with .Net framework version 1.1.
    I am able to catch all the exceptions and redirect to Custom error screen.
    However if I enter the invalid characters in URL specifically  '|', '"' and '~' it throws "ArgumentException" with message as "?" and not able to redirect this to Custom error screen.
    All other invalid characters and symbols are being handled properly. Custom error screen is set in WEB.config and it is working for all the exceptions.
    Please help me find a way to catch and redirect this exception to Custom error screen.

    Hello Mr. Monkeyboy,
    One of the security solutions ran a security test by entering the wrong characters in the URL (Few more cases) and there by finding if the site redirects to Custom webpage in case of errors and exceptions or not.
    Our site is redirecting to Custom error page for all the errors and exceptions except when entered '|','"' or '`' in the url.
    Example: If I enter: https://www.somesite.com/NotExists.aspx this get redirected to Custom error screen.
    However If I enter https:////www.somesite.com/NotExi|sts.aspx this goes to Server Error in "/somesite" page.
    Please note, both the URL is invalid, however one redirects to Custom error where another doesn't.
    Thanks for letting me know the lack of clarity in the initial question, hope I made it clear.
    I still don't understand the issue. And you should probably be posting the question in one of the ASP.Net forums which I provided a link to in my original post.
    You say you enter a URL in your website. But you make no mention of how that is done. Therefore even if you post a question in one of the ASP.Net forums you will need to explain what you mean by entering a URL in your Website.
    For example. "We have a website. A user can browse to the website with a WebBrowser. Then in a textbox on the website they can enter a URL (for whatever reason your website would allow a user browsing your website with a webbrowser to want to enter
    some URL for some reason into a textbox at your website) and select a button (to do who knows what) and we need to validate the URL does not contain invalid characters."
    Maybe these links can help or not.
    Validator.Url Method
    PathIsURL function
    Pinvoke.Net - pathisurl (shlwapi)
    Uri.TryCreate Method
    I suppose you could even use Regex to validate a URL based on Regex patterns that you should be able to find on the net for doing so with Visual Basic. But I would suppose you would want to provide whoever is placing invalid URL's on the website with the
    result displaying the invalid URL and which characters within it are invalid maybe.
    I suspect you could even try to validate a URL with a DNS by finding out if it exists or not.
    La vida loca

Maybe you are looking for

  • How can I delete all of my photos at once?

    I need more space on my iPhone (5, recently upgraded to iOS 8), so I need to delete all of my photos (which my Mac says have all been uploaded to iPhoto). When I try to use the "delete all" option in iPhoto, nothing actually happens. Thanks!

  • Spry vertical menu problem with IE

    We implemented the spry vertical menu for showing the categories of a products catalog. It has almost 1800 categories organizad at about 5 levels, some categories have about 30 subcategories. These categories are extrated from a database. It works in

  • Changing The IPOD name

    Ive erased my ipod and tried to reload Itunes, but I'm not at my computer so it keeps labeling it as the person who owns the computer. How do I change this?

  • I would like to recover photos that are in Trash in IPhoto and restore them to either specific albums or the general photo list

    I have inadvertently deleted over 600 photos to trash. I would like to restore them either to the general photo list or move them to albums. The deleted photos and videos all are intact but I don't know how to transfer them to a folder where I can us

  • Does anyone sell software bundle that came wG5

    Here's what I'm talking about: Mac OS X, Spotlight, Dashboard, Mail, iChat AV, Safari, Address Book, QuickTime, iLife (includes iTunes, iPhoto, iMovie HD, iDVD, and GarageBand), iCal, DVD Player, Classic environment, Art Directors Toolkit X, FileMake