The following code example demonstrates how to Redirect Another Page Using JSP.
In this code, the sendRedirect
method of the response
object is used to redirect to the specified URL. The URL can be a relative or an absolute path, depending on your needs.
Note that the sendRedirect
method sends a 302 Found
HTTP response to the client, which causes the client to make a new request to the specified URL.
In order to redirect to another page using JSP, you can use the following code.
<% response.sendRedirect("http://www.example.com/newPage.jsp"); %>
The following code shows the complete application in JSP that redirects to another page.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Redirect Example</title>
</head>
<body>
<%
response.sendRedirect("http://www.example.com/newPage.jsp");
%>
</body>
</html>
As can be seen in the above code, we use the sendRedirect() method to redirect to another page in JSP.
Further Reading
Understanding Enterprise Java Beans
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- Extended Reality
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML