AW: [opencms-dev] Real Client IP address in Open CMS
Peter Hagl
Peter.Hagl at gmx.at
Tue Aug 19 12:50:02 CEST 2003
Dear Miller
I have tried your code but it always show 127.0.0.1 but that is my localhost
and not my IP-address.
What is wrong?
Please help me.
Peter
> 1. Make a new JSP page
>
> 2. Copy in the following code (without the codebegin, codeend lines !)
>
> CODEBEGIN-----------------------------------------
>
> <%@ page import="com.opencms.flex.jsp.*" %>
> <%
> // Create a JSP action element
> com.opencms.flex.jsp.CmsJspActionElement cms = new
> CmsJspActionElement(pageContext, request, response);
>
> HttpServletRequest req =
> (HttpServletRequest)cms.getRequestContext().getRequest().getOriginalReque
> st();
>
> String ip=req.getRemoteAddr();
>
> out.println(ip);
> %>
>
> ----------------------------------------- CODEEND
>
> 3. Save the page
>
> 4. Open the page
>
> any other info on the HttpServletRequest interface can be found at
> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletReque
> st.html
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: opencms-dev-admin at opencms.org
> [mailto:opencms-dev-admin at opencms.org] Im Auftrag von Peter Hagl
> Gesendet: 19 August 2003 09:07
> An: opencms-dev at opencms.org
> Betreff: [opencms-dev] Real Client IP address in Open CMS
>
> DearUsers
>
> The problem is that I want to get the real IP address of the client. Not
> even 127.0.0.1. This Ip address is the localhost.
> But I want to get 240.250.4.125. How can I find out the real IP address
> of
> the client in OpenCms.
> Please help me and send me an example code.
>
> Peter
>
>
>
>
> > Why not just use the HttpServletRequest object that you are passing to
> > CmsJspActionElement in the first place?
> >
> > E.g. "CmsJspActionElement cms = new CmsJspActionElement(pageContext,
> > request, response);" -- the object 'request' is a HttpServletRequest
> > object, is it not?
> >
> > On Mon, 2003-08-18 at 02:57, Peter Hagl wrote:
> > > Dear Users
> > >
> > > My latest tried code gives the following errors. Can you help me?
> What
> > is
> > > wrong?
> > >
> > > Your's
> > >
> > > Peter
> > >
> > > <%@ page
> import="java.util.*,javax.servlet.*,com.opencms.flex.jsp.*" %>
> > <%
> > >
> > > CmsJspActionElement cms = new CmsJspActionElement(pageContext,
> request,
> > > response);
> > >
> > > HttpServletRequest req
> > >
> =(HttpServletRequest)cmsobject.getRequestContext().getRequest().getOrig
>
> > inalR
> > > equest();
> > > String ip=req.getRemoteAddr();
> > >
> > >
> > > out.println("<h3>A simple sample
> > > navigation</h3>");
> > > out.println(""+ip);
> > >
> > > %>
> > >
> > >
> >
> -------------------------------------------------------------------------
>
> > ------------------------
> > > Root cause:
> > > org.apache.jasper.JasperException: Unable to compile class for JSP
> > >
> > > An error occurred at line: -1 in the jsp file: null
> > >
> > > Generated servlet error:
> > > [javac] Since fork is true, ignoring compiler setting.
> > > [javac] Compiling 1 source file
> > > [javac] Since fork is true, ignoring compiler setting.
> > > [javac] D:\Tomcat
> > >
> >
> 4.1\work\Standalone\localhost\opencms\WEB-INF\jsp\offline\system\modules\
>
> > Mee
> > > tingroom\elements\tt_jsp.java:48: cannot resolve symbol
> > > [javac] symbol : variable cmsobject
> > > [javac] location: class org.apache.jsp.tt_jsp
> > > [javac] HttpServletRequest req
> > >
> =(HttpServletRequest)cmsobject.getRequestContext().getRequest().getOrig
>
> > inalR
> > > equest();
> > > [javac] ^
> > > [javac] 1
> > > error
> > >
> > >
> >
> -------------------------------------------------------------------------
>
> > ----------------------------------------------------------------
> > >
> > >
> > >
> > >
> > >
> > > > When you get a resource loader error, there is usually a detailed
> > > > explanation a but further down telling you which line of code and
> at
> > > > which position and in which file the app is in error.
> > > >
> > > > You need to try a little debugging, I
> don̉̉t know if your err
> > or is
> > > > simply
> > > > >from copy paste, but for example, you have missed a semi-colon in
> > your
> > > > first line of code.
> > > >
> > > > You should only need to scroll 2 or 3 lines down to see the error
> > > > report, or you can copy the whole error report to notepad or any
> > editor
> > > > for easier viewing.
> > > >
> > > > Happy debugging,
> > > >
> > > > mark
> > > >
> > > > -----UrsprÃÆüngliche Nachricht-----
> > > > Von: opencms-dev-admin at opencms.org
> > > > [mailto:opencms-dev-admin at opencms.org] Im Auftrag von Peter Hagl
> > > > Gesendet: 18 August 2003 10:25
> > > > An: opencms-dev at opencms.org
> > > > Betreff: Re: [opencms-dev] Real Client IP address in Open CMS
> > > >
> > > > Hi Achim
> > > >
> > > > Can you help me. How can I built an API into OpenCMS. Can you
> please
> > > > send me
> > > > a hole example code that is running.
> > > >
> > > > I have tried so much, but nothing works:
> > > >
> > > > e.g.
> > > > ObjectInputStream inStream = new
> > > > ObjectInputStream(request.getInputStream());
> > > > String myRequestObject = (String)inStream.readObject();
> > > >
> > > > That' s why I need a hole example which includes all definitions
> like
> > > > libaries, JSP and so on. Because I get every time errors like
> > > > Recource loader errors and I don't know if it is from the
> environment
> > o
> > r
> > > > >from my code. Please send me an code example which I can just
> pick
> > out
> > > > with copy
> > > > and paste and that is working.
> > > >
> > > > That will be really nice from you.
> > > >
> > > > Thank' s a lot
> > > >
> > > > Peter
> > > >
> > > >
> > > > > Hi Peter,
> > > > >
> > > > > this is nothing that belongs Opencms, this belongs to the Sun
> J2EE
> > > > API.
> > > > >
> > > > > There you have a Object, called Request. This object brings all
> > > > Enviroment
> > > > > variables from the Client. There you can do something like that:
> > > > > String sIpadress = myRequestObject.REMOTE_ADDR;
> > > > >
> > > > > Hope this helps
> > > > >
> > > > > Achim
> > > > >
> > > > > > I have read the email "real client ip adress" in OpenCms but I
> > have
> > > > not
> > > > > > understood how I can use the Request Object and how I can read
> out
> > > > the
> > > > > > REMOTE_ADDR. Can anyone send me an example about that. I' m a
> > > > newcomer
> > > > > > of OpenCMS. I don' t know anything about the Request Object
> and
> > the
> > > > > > REMOTE_ADDR.
> > > > > >
> > > > > > Any help is appreciated. Thank you very much for your support
> > > > > >
> > > > > > Best regards
> > > > > >
> > > > > > Peter
> > > > > >
> > > > > > --
> > > > > > COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
> > > > > > --------------------------------------------------
> > > > > > 1. GMX TopMail - Platz 1 und Testsieger!
> > > > > > 2. GMX ProMail - Platz 2 und
> Preis-QualitÃÆätssieger!
> > > > > > 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7.
> daybyday -
> > > > 8.
> > > > > > e-Post
> > > > > >
> > > > > > _______________________________________________
> > > > > > This mail is send to you from the opencms-dev mailing list
> > > > > > To change your list options, or to unsubscribe from the list,
> > pleas
> > e
> > > > > > visit http://mail.opencms.org/mailman/listinfo/opencms-dev
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > This mail is send to you from the opencms-dev mailing list
> > > > > To change your list options, or to unsubscribe from the list,
> please
> > > > visit
> > > > > http://mail.opencms.org/mailman/listinfo/opencms-dev
> > > > >
> > > >
> > > > --
> > > > COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
> > > > --------------------------------------------------
> > > > 1. GMX TopMail - Platz 1 und Testsieger!
> > > > 2. GMX ProMail - Platz 2 und
> Preis-QualitÃÆätssieger!
> > > > 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday -
> 8.
> > > > e-Post
> > > >
> > > > _______________________________________________
> > > > This mail is send to you from the opencms-dev mailing list
> > > > To change your list options, or to unsubscribe from the list,
> please
> > > > visit
> > > > http://mail.opencms.org/mailman/listinfo/opencms-dev
> > > >
> > > >
> > > > _______________________________________________
> > > > This mail is send to you from the opencms-dev mailing list
> > > > To change your list options, or to unsubscribe from the list,
> please
> > vi
> > sit
> > > > http://mail.opencms.org/mailman/listinfo/opencms-dev
> > > >
> > --
> > M Butcher <mbutcher at grcomputing.net>
> > _______________________________________________
> > This mail is send to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please
> visit
> > http://mail.opencms.org/mailman/listinfo/opencms-dev
> >
>
> --
> COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
> --------------------------------------------------
> 1. GMX TopMail - Platz 1 und Testsieger!
> 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
> 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8.
> e-Post
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
> visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>
--
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post
More information about the opencms-dev
mailing list