you have already forwarded the response in catch block:
RequestDispatcher dd = request.getRequestDispatcher("error.jsp"); dd.forward(request, response);
so, you can not again call the :
response.sendRedirect("usertaskpage.jsp");
because it is already forwarded (committed).
So what you can do is: keep a string to assign where you need to forward the response.
String page = ""; try { } catch (Exception e) { page = "error.jsp"; } finally { page = "usertaskpage.jsp"; } RequestDispatcher dd=request.getRequestDispatcher(page); dd.forward(request, response);
Related Posts:
- getting error HTTP Status 405 – HTTP method GET is not supported by this URL but not used `get` ever?
- java.lang.NumberFormatException: null i
- WebServlet cannot be resolved to a type
- Response has aready been committed
- What is the difference between JSF, Servlet and JSP?
- How to specify the default error page in web.xml?
- Spring Boot – Unable to resolve Whitelabel Error Page
- What is Java Servlet?
- What does request.getParameter return?
- How to request.getParameterNames into List of strings?
- What is IllegalStateException?
- Session TimeOut in web.xml
- What is the difference between response.sendRedirect() and request.getRequestDispatcher().forward(request,response)
- How to solve javax.net.ssl.SSLHandshakeException Error?
- Uri not Absolute exception getting while calling Restful Webservice
- org.apache.jasper.JasperException: Unable to compile class for JSP:
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- HTTP Status 500 Error instantiating servlet class
- What does this expression language ${pageContext.request.contextPath} exactly do in JSP EL?
- An established connection was aborted by the software in your host machine tomcat jackson
- what is the difference between doGet() and doPost() in term of the flow?
- Static Final Long serialVersionUID = 1L
- getOutputStream() has already been called for this response
- The import javax.servlet can’t be resolved
- How do I “decompile” Java class files? [closed]
- How do I compare strings in Java?
- Could not reserve enough space for object heap
- What does “Could not find or load main class” mean?
- What is null in Java?
- What is an illegal reflective access?
- Convert Set to List without creating new List
- MacOS Catalina(v 10.15.3): Error: “chromedriver” cannot be opened because the developer cannot be verified. Unable to launch the chrome browser
- Can I catch multiple Java exceptions in the same catch clause?
- What is the use of printStackTrace() method in Java?
- How do I limit the number of decimals printed for a double?
- Please initialize the log4j system properly warning
- how to iterate in List
- > in java and set their values as we do in a normal int a[i][j] matrix type [duplicate]
- Java – Best way to print 2D array?
- How to update a value, given a key in a hashmap?
- How to schedule a periodic task in Java?
- Recompile with -Xlint:unchecked for detail error in java
- Convert array of strings into a string in Java
- What is Serialization?
- SSL and cert keystore
- What’s the difference between import java.util.*; and import java.util.stream;?
- Collections sort(List
,Comparator super T>) method example - Login Application with 1 stage and multiple scene in JavaFX
- Handle mouse event anywhere with JavaFX
- Choosing the best concurrency list in Java
- Why nextLine() and not nextString() ?
- Very Basic Java
- What is the meaning of “%d:%02d” in `printf`?
- Type List vs type ArrayList in Java
- Maven error : Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
- Polymorphism vs Overriding vs Overloading
- Difference between Static methods and Instance methods
- Java The method is undefined for this type
- Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio
- How to convert a byte array to a hex string in Java?
- How to get the last value of an ArrayList
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- How to check if the value is integer in java?
- Java Error: Invalid top level statement
- How to make an array of arrays in Java
- Instantiating object of type parameter
- How to convert an Instant to a date format?
- equivalent to push() or pop() for arrays?
- JaxbRepresentation gives error “doesnt contain ObjectFactory.class or jaxb.index”
- How do I fix a NoSuchMethodError?
- What is the Java equivalent for LINQ?
- “Expression expected” and “Cannot find symbol” error
- Android Studio ERROR: Cannot resolve symbol ‘View’
- Static Initialization Blocks
- “Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar” when starting the Scala interpreter
- Swing/Java: How to use the getText and setText string properly
- Get keys from HashMap in Java
- Converting a 2-3-4 tree into a red black tree
- Generic stack implementation
- Java generating non-repeating random numbers
- java eclipse red exclamation mark
- Java FileOutputStream Create File if not exists
- Configure active profile in SpringBoot via Maven
- Is there any way to program Java on Visual Studio 2015
- Keylistener not working for JPanel
- the getSource() and getActionCommand()
- Failed to install android-sdk: “java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema”
- Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven
- Regex pattern including all special characters
- Error: ‘)’ expected compiler error
- How does addNotify() and requestFocus() work in Java with JPanel?
- DTO and DAO concepts and MVC
- Exception is never thrown in body of corresponding try statement
- Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2)
- Using while loop as input validation [duplicate]
- java -version and javac -version showing different versions
- when spring boot startup,throw out the “method names must be tokens” exception
- How to get javax.comm API?
- how to convert exe file to .jar file? [duplicate]
- How to print a table of information in Java
- set background color: Android