Results 1 to 7 of 7
- 12-15-2011, 09:14 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 25
- Rep Power
- 0
JSP and javascript - assignment problem
Hi,
I have a problem with my code:
<code>
<%
String ip=request.getRemoteAddr().toString();
System.out.println(ip); // prints the currect IP ADRESS as a string
%>
var ip = <%= ip %>;
alert (ip); //DOESNT WORK!
</code>
the alert(ip) doesnt work at all..
any ideas why?
- 12-15-2011, 09:23 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: JSP and javascript - assignment problem
Look at the source the page creates and make sure it produces what you expect, and if so make sure what you expect is valid javascript syntax
- 12-16-2011, 06:26 AM #3
Member
- Join Date
- Aug 2011
- Location
- INDIA
- Posts
- 64
- Rep Power
- 0
Re: JSP and javascript - assignment problem
as per my knowledge ,here alert is from javascript while you are working in java and jsp .Make sure that you are using right component .correct me if i am wrong as i dont know so much in jsp but knows javascript
I can and I will.gif)
- 12-16-2011, 09:37 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: JSP and javascript - assignment problem
Is the javascript inside a SCRIPT tag?
What do you see on the page in the browser?
- 12-19-2011, 12:18 PM #5
Member
- Join Date
- Aug 2011
- Location
- INDIA
- Posts
- 64
- Rep Power
- 0
Re: JSP and javascript - assignment problem
remove var ip = and run it again it works
- 12-19-2011, 12:42 PM #6
Member
- Join Date
- Jul 2011
- Posts
- 25
- Rep Power
- 0
- 12-19-2011, 01:00 PM #7
Member
- Join Date
- Aug 2011
- Location
- INDIA
- Posts
- 64
- Rep Power
- 0
Similar Threads
-
Javascript Menu Problem
By michael_socialm in forum New To JavaReplies: 4Last Post: 05-29-2011, 05:51 PM -
AJAX + Javascript problem
By dapikk in forum New To JavaReplies: 3Last Post: 02-22-2011, 03:12 PM -
sorry to ask a javascript problem but please help
By javastuden in forum New To JavaReplies: 1Last Post: 12-23-2009, 07:33 AM -
Javascript problem
By luca.santaniello in forum Advanced JavaReplies: 2Last Post: 11-18-2009, 10:27 PM -
New Line problem in javascript
By shuvra_pan in forum Advanced JavaReplies: 3Last Post: 03-18-2009, 03:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks