07-28-2007 08:39 PM - edited 03-13-2019 04:19 PM
when the ip phone request my services, how can i get the phone's device name or ip?
thanks^_^
07-30-2007 12:36 AM
Hello,
quite easy. Look at the [HTTP] global variables of your applications.
For instance, if your services are PHP-based, then this should help:
http://sk.php.net/manual/en/reserved.variables.php#reserved.variables.server
You are looking for
$_SERVER['REMOTE_ADDR'] or
$_SERVER['REMOTE_HOST']
If ASP, then
Request.ServerVariables("remote_addr") or
Request.ServerVariables("remote_host")
07-30-2007 12:39 AM
thanks, it works, but in JSP, how can i get the deveicename(i can get the remoteip)?
thanks for advanced.
07-30-2007 12:49 AM
Google is your best friend ;-)
Those are standard CGI variables, must be available in PHP/ASP(X)/JSP/your-favorite.
Anyway, try this:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
/** Creates a table showing the values of all the CGI variables.
*
* Part of tutorial on servlets and JSP that appears at * http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/ * 1999 Marty Hall; may be freely used or adapted. */ public class ShowCGIVariables extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String[][] variables = { { "AUTH_TYPE", request.getAuthType() }, { "CONTENT_LENGTH", String.valueOf(request.getContentLength()) }, { "CONTENT_TYPE", request.getContentType() }, { "DOCUMENT_ROOT", getServletContext().getRealPath("/") }, { "PATH_INFO", request.getPathInfo() }, { "PATH_TRANSLATED", request.getPathTranslated() }, { "QUERY_STRING", request.getQueryString() }, { "REMOTE_ADDR", request.getRemoteAddr() }, { "REMOTE_HOST", request.getRemoteHost() }, { "REMOTE_USER", request.getRemoteUser() }, { "REQUEST_METHOD", request.getMethod() }, { "SCRIPT_NAME", request.getServletPath() }, { "SERVER_NAME", request.getServerName() }, { "SERVER_PORT", String.valueOf(request.getServerPort()) }, { "SERVER_PROTOCOL", request.getProtocol() }, { "SERVER_SOFTWARE", getServletContext().getServerInfo() } }; String title = "Servlet Example: Showing CGI Variables"; out.println(ServletUtilities.headWithTitle(title) + "\n" + "
CGI Variable Name | Value"); for(int i=0; i |
---|---|
" + varName + " | " + varValue); } out.println(" |
07-30-2007 01:37 AM
Thanks for your advices!
maybe the "deveice Name" is not included by CGI variables.
let'me test, thanks a lot
07-30-2007 03:14 AM
The standard way to get the device name is to make the phone append it when making the first request to a service..
http://your-application-server/path/myapplication?device=#DEVICENAME#
Then you get that variable and store it in a session variable. There's really almost never a need to go by IP.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide