Obtain the URL of the previous page and the URL of this page.
1. Obtain the URL of the previous webpage:
String url=request.getHeader("Referer");
2. Obtain the URL of this webpage:
String url=request.getScheme()+"://"+ request.getServerName()+request.getRequestURI();
How does ASP obtain the URL on this page?
The method is as follows:
<%
Private Function GetUrl ()
Dim ScriptAddress, M_ItemUrl, M_item
ScriptAddress = CStr (Request. ServerVariables ("SCRIPT_NAME") 'gets the current address
M_ItemUrl = ""
If (Request. QueryString <> "") Then
ScriptAddress = ScriptAddress &"? "
For Each M_item In Request. QueryString
If InStr (page, M_Item) = 0 Then
M_ItemUrl = M_ItemUrl & M_Item & "=" & Server. URLEncode (Request. QueryString ("" & M_Item &""))&"&"
End If
Next
End if
GetUrl = ScriptAddress & M_ItemUrl
End Function
Response. write geturl ()
%>
Yes, you can obtain part of the URL. Test it.
In PHP, how do I obtain the URL of the previous page?
$ _ SERVER ['HTTP _ referer']