Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Request. ServerVariables ( REMOTE_USER") equalent in jsp  RSS feed

 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any thing equalent of Request.ServerVariables("REMOTE_USER") in jsp if not how to get Nt userlog on id in jsp or servlet.
thanks in advance
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html#getRemoteUser()
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am looking for logged in user sorry i am not clear in my question its
Request.ServerVariables("LOGON_USER")
remote user gives machine name not the logged in user id ?
who ever logs into the machine same machine name its giving !
thanks for the responce
[ November 20, 2005: Message edited by: kamesh aru ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The link I sent to you lists all of the methods of the HttpServletRequest and it's parent ServletRequest.
 
Bob Frapples
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, thanks Ben. The question remains, does anyone out there know how to get server variables in JSP?
 
C Broussard
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just for clarification you mean System.getProperty("") equivalent for jsp or something else?

I'm not sure if one exists, but you could easily code up a customtag for that worst case.

www.binaryfrost.com
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bob Frapples:
Okay, thanks Ben. The question remains, does anyone out there know how to get server variables in JSP?


I assume you are talking about the ServerVariables property of the Request object in Microsoft ASP.
If not, correct me.
If so, this property is particular to ASP/IIS and is not part of any open protocol.

Here is a quote from MSDN describing the ServerVariables property:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/9768ecfe-8280-4407-b9c0-844f75508752.asp


You should be able to pull the same information using the methods of HttpServletRequest, just not with one call.
 
Bob Frapples
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, here's the solution:

request.getHeader("yourVariableNameHere");

The API gives the following description (which leaves a lot to be desired) for this function: "Returns the value of the specified request header as a String." I'm thinking it might have been better to say it returns the value of the specified server/header variable, but whatever...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, "ServerVariable" is an IIS/ASP thing (and, in my opinion, is a bit vauge).

HTTP Headers are a part of the HTTP protocol spec.
The description in the HttpServletRequest API, as far as I can see, is dead on.

Anyway, I'm glad you found a solution.
-Ben
[ December 02, 2005: Message edited by: Ben Souther ]
 
Bob Frapples
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben, I'm not sure what you're saying. The OP asked for the Java "equivalent" to the ASP ServerVariables construct from the very beginning, with the understanding that ASP and ServerVariables is a foreign concept to Java...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob,
Good point, we strayed from the original poster's question.
I was responding to your question:
The question remains, does anyone out there know how to get server variables in JSP?


kamesh,

JSP is not as tightly integerated with Windows as IIS.
I don't think your going to find a method that gets what you're looking for.

You may want to look at:
HttpServletRequest.getUserPrincipal
but I don't think that's going to do it for you either.

-Ben
 
Bob Frapples
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But Ben, I just posted the solution :-)
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bob Frapples:
But Ben, I just posted the solution :-)


You posted the code for retrieving a request header.
I think was the original poster was looking for was the NT Logon.
I don't think he's going to find that in the request headers.

[kamesh:]
...if not how to get Nt userlog on id in jsp or servlet.
thanks in advance


IIS ServerVariables include request headers but also have IIS specific entries that are not standard HTTP Request Headers.
 
Anwar Jabr
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there, I think that the best way to do that is to let an asp page collects the variable you want and to pass that variable to the jsp page throw parameter.
for me I used the following asp page
<form name="form1" action="http://localhost:8080/WebModule1/jsp1.jsp" method="post" ID="Form1">
<INPUT id="Submit1" style="Z-INDEX: 101; LEFT: 88px; WIDTH: 0px; POSITION: absolute; TOP: 88px; HEIGHT: 0px"
type="submit" value="Submit" name="Submit1" size="1">
<INPUT id="Text1" style="Z-INDEX: 103; LEFT: 80px; WIDTH: 72px; POSITION: absolute; TOP: 56px; HEIGHT: 24px"
type="hidden" size="6" name="Text1" value=<%=Request.ServerVariables("LOGON_USER")%>>
<script id="test" language="javascript">
document.forms("form1").submit();
</script>
</form>

and on the jsp site, the jsp page named jsp1.jsp as follows
<html>
<head>
<title>
jsp1
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<form method="post" action="jsp1.jsp">
<br><br>
<%
String a = request.getParameter("Text1");
out.println("user="+a);
%>
</form>
</body>
</html>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!