Đối tượng response trong JSP

Đối tượng response trong JSP

Đối tượng response trong JSP

Learn more »

Đối tượng response trong JSP



Đối tượng response trong JSP là một đối tượng ẩn của javax.servlet.http.HttpServletResponse. Cũng như việc server tạo ra các đối tượng resquest, nó cũng tạo ra một đối tượng response để đại diện cho các phản hồi cho client.

Đối tượng response cũng định nghĩa các giao diện để tạo ra HTTP header mới. Thông qua đối tượng này, lập trình viên JSP có thể thêm cookie mới hoặc date stamps, HTTP status code, chuyển hướng, vv.


Ví dụ về đối tượng response trong JSP

Dưới đây là ví dụ sử dụng đối tượng response để chuyển hướng người dùng đến một trang web khác.

Tạo trang index.html

 <form action="welcome.jsp">   <input type="text" name="username">    <input type="submit" value="Submit"> </form> 

Tạo trang welcome.jsp

 <%     response.sendRedirect("http://www.google.com"); %> 

Kết quả:

Đối tượng response trong JSP

click Submit.

Đối tượng response trong JSP


Lượt xem : 278

Integrations
Users

Share Profile

Anyone at KeenThemes can view
Anyone with link can edit

Give Award

Anyone at KeenThemes can view
Anyone with link can edit

Report User

Let us know why you’re reporing this person
Don't worry, your report is completely anonymous; the person you're
reporting will not be informed that you've submitted it