`
遠大前程
  • 浏览: 7119 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类
最新评论

encodeURL and encodeRedirectURL

阅读更多
If the client doesn't accept cookies,we can use URL rewriting as a backup. URL rewriting will always work.URL rewriting takes the session ID that is in the cookie and sticks it right onto the end of every URL that comes in to this app.When the user clicks that "enhanced "link ,the request goes to the container with that extra bit on the end ,and the Container simply strips off the extra part of the request URL and uses it to find the matching session.URL rewriting kicks in only if cookies fail,and only if you  tell the response to encode the URL.If you want the container to always default to using cookies first,with URL rewriting only as a last resort.You should explicitly encode your URLs,and the client would accept cookies,you get to use sessions,and the container will first attempt to use cookies for session management.
You code should like :

HttpSession session = request.getSession();//Get a session.
out.println("<a href\""+response.encodeURL("/BeerTest.do")+"\">click me</a>"); //Add the extra session ID info to this URL.


You want to redirect the request to a different URL ,but you still want to use a session.There is a special URL encoding method just for that:

response.encodeRedirectURL("/BeerTest.do")
分享到:
评论

相关推荐

    javaScript encodeURI中文乱码

    ### JavaScript encodeURI中文乱码问题解析与解决方案 在Web开发中,处理中文字符或其它非ASCII字符时,经常遇到的问题之一就是编码问题,特别是在URL处理过程中。JavaScript中的`encodeURI()`函数是用于对URL进行...

    URL传中文参数导致乱码的解决方案之encodeURI

    为了解决这个问题,我们可以利用JavaScript中的`encodeURI`函数来对中文参数进行编码,然后在服务端进行相应的解码操作。 `encodeURI`函数是JavaScript提供的一个内置方法,它的作用是对整个URL进行编码,包括特殊...

    JS的encodeURI和java的URLDecoder.decode使用介绍

    如果不想在url中看到有明文,比如http://localhost:8080/template_1/login.action?user=张三 可以使用js的encodeURI的URLDecoder.decode一起使用一起来把url加密下 (1)JS在页面上把数据var val = encodeURI...

    encodeURIComponent encodeURI 中文转GBK编码

    serialize , encodeURIComponent encodeURI 中文转成GBK编码 encodeURIComponent encodeURI 默认转 utf-8 ;重写方法 转成GBK

    js的encodeUri编码转换为GBK问题

    在JavaScript中,`encodeURI`函数是用来对URI(统一资源标识符)进行编码的,它遵循RFC 3986标准,保留了某些特殊字符不被编码,如空格被编码为`+`,这对于HTTP请求是必要的。然而,当我们需要处理中文或其他非ASCII...

    JS中三种编码方式(escape,encodeURI,encodeURIComponent)

    常见的三种编码方法是`escape`、`encodeURI`和`encodeURIComponent`。这些函数各有其特定的用途,理解和掌握它们的区别对于编写健壮的JavaScript代码至关重要。 1. `escape` 函数: `escape`方法主要用于对字符串...

    escape、encodeURI、encodeURIComponent 区别详解

    ### escape、encodeURI、encodeURIComponent 区别详解 在前端开发中,经常需要用到字符串编码与解码的方法来确保数据在网络传输中的正确性与安全性。本文将详细介绍 `escape()`、`encodeURI()` 和 `...

    javascript中encodeURI和decodeURI方法使用介绍.docx

    ### JavaScript中encodeURI和decodeURI方法使用介绍 #### 一、基本概念 在JavaScript中,`encodeURI`和`decodeURI`是一对用于处理URL编码的重要函数。它们主要用于解决URL中包含非ASCII字符时可能出现的问题。 - ...

    JSP中js传递和解析URL参数以及中文转码和解码问题

    1.传递参数: 代码如下: var pmt = ‘sensor=’+ encodeURI(encodeURI(sensor))+’&device=’+encodeURI(encodeURI(device))+’&instrument=’; pmt += encodeURI(encodeURI(instrument))+’&n=’+n+’&addDate=’+...

    JS的encodeURI和java的URLDecoder.decode使用介绍.docx

    ### JS的encodeURI和Java的URLDecoder.decode使用详解 #### 一、背景介绍 在网络通信过程中,URL(统一资源定位符)作为传输信息的一种常见方式,其安全性与隐私性问题一直备受关注。为了提高URL的安全性和隐私性,...

    escape、encodeURI 和 encodeURIComponent 的区别

    在JavaScript中,`escape()`, `encodeURI()`, 和 `encodeURIComponent()` 是三个常见的字符串编码函数,它们用于处理和转换字符串中的特殊字符。虽然它们都与字符串编码有关,但各自的作用和适用场景有所不同。 ...

    JavaScript encodeURI 和encodeURIComponent

    encodeURI和encodeURIComponet函数都是javascript中用来对URI进行编码,将相关参数转换成UTF-8编码格式的数据。URI在进行定位跳转时,参数里面的中文、日文等非ASCII编码都会进行编码转换

    谈谈encodeURI和encodeURIComponent以及escape的区别与应用

    在JavaScript中,`encodeURI()`、`encodeURIComponent()`和`escape()`是三个用于字符串编码的函数,它们的主要目的是确保特殊字符在传输过程中不会引起错误。理解它们之间的差异对于编写正确处理URL和数据的...

    Javascript中escape(),_encodeURI()和encodeURIComponent()之精析与比较.doc

    在JavaScript中,`escape()`, `encodeURI()`, 和 `encodeURIComponent()` 是三个常见的字符串编码函数,它们各自有独特的用途和特点。理解它们的区别对于编写健壮的JavaScript代码至关重要。 首先,`escape()` 函数...

    简单明了区分escape、encodeURI和encodeURIComponent

    本文主要关注三个与URL编码相关的函数:`escape`、`encodeURI`和`encodeURIComponent`。这些函数各有其特定的用途,理解它们的区别至关重要。 首先,我们来看`escape`函数。`escape`并不专门用于URL编码,它实际上...

    深入分析escape()、encodeURI()、encodeURIComponent()的区别及示例

    在JavaScript中,处理字符串编码时,有三个关键函数:`escape()`、`encodeURI()`和`encodeURIComponent()`。它们各自有不同的用途和特点,理解它们的区别对于正确处理URL和URI至关重要。 1. `escape()`函数: `...

    ios获取数据之encodeURI和decodeURI的实例

    iOS 获取数据之 encodeURI 和 decodeURI 的实例 本文将详细介绍 iOS 中的 encodeURI 和 decodeURI 函数的使用实例,主要涉及到 URL 编码和解码的知识点。 一、encodeURI 函数 encodeURI 函数将字符串作为 URI ...

Global site tag (gtag.js) - Google Analytics