Response Object is the object of  HttpServletResponse class associated with the response to the client. It is different from the request object since the request is the object of HttpServletRequest class associated with the request.

 

We will cover three ways to link pages with HTML, Javascript, and JSP. It is the same function, but each language has different codes to link the page. first.jsp is the file that we will link in each files. 

 

first.jsp

<%@ page contentType = "text/html; charset=utf-8" %>

<%

String str = request.getParameter("name");

%>

name : <%=str%>

 

meta.html

The good thing when you use the meta tag in HTML is that you can set the time.

<html>
	<head>

	<!-- mata tag -->
	<meta http-equiv="refresh" content="0;
		url=first.jsp?name=test">

	</head>
	<body>
	</body>
</html>

The url will link to the first.jsp file. This is a get method. If you are using a form, you can choose either get method or post method, but in this case, you cannot. 

 

With Javascript, you can use the alert() and location property.

location.html

<html>
	<head>
	<meta charset="utf-8">
	</head>
	<body>

	<script language="javascript">
		alert("Page link");
		location.href='first.jsp?name=test';
	</script>

	</body>
</html>

With JSP, you can use a response object. 

responseEx.jsp

<%@ page contentType="text/html;charset=utf-8"%>

<h1>Response Example</h1>
This page is from responseEx.jsp file.


<%	//Page link from JSP
     response.sendRedirect("first.jsp?name=test");
%>

 

'Java > JSP' 카테고리의 다른 글

JSP) Encoding Korean 한글 인코딩  (0) 2022.08.27
JSP) Implicit Objects 3 - Out Object  (0) 2022.08.27
JSP) Implicit Objects 1 - Request Object  (0) 2022.08.26
JSP) Scopes - Basics / Application  (0) 2022.08.26
JSP) Comment  (0) 2022.08.26

+ Recent posts