/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Retriving variables to next page by using javascript

I have a jsp page called display.jsp ,where i have a hyperlink which redirects to a HTML page called check.html.

[B]display.jsp[/B]

[code]
%@ page language=”java” contentType=”text/html; charset=ISO-8859-1″
pageEncoding=”ISO-8859-1″%>
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″>
<title>Insert title here</title>
</head>
<body>
<% String FromAdd= “delhi”;
session.setAttribute(“from” , FromAdd);
String ToAdd = “agra”;
session.setAttribute(“to” , ToAdd);
%>
<a href=”check.html” >Click here </a>
</body>
</html>
[/code]

……………………………………………………………
check.html

[code]
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″>
<title>Insert title here</title>
<script type=”text/javascript”>
function intialize()
{

[COLOR=”Red”]here temme hw i can retrive the values of FromAdd and ToAdd form abv page and display them [/COLOR]

}
</script>
</head>
<body onload=”initialize()”>

</body>
</html>
[/code]

so what i want to know is how i can retrive the values of FromAdd and ToAdd from check.html’s javascript funt ..i.e intialize();

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 17.2010 — var from = '&lt;&amp;#37; (String) session.getAttribute("from"); %&gt;';
Copy linkTweet thisAlerts:
@padmaharikaauthorApr 17.2010 — thnk for d reply fang ...but i m stil facing a prblm.

first of all my 2nd page is a html file where the tags <% %> wouldnt work

more over i even tried it using jsp,it gave a error saying :

Multiple annotations found at this line:

- Syntax error, insert "AssignmentOperator Expression" to complete

Assignment

- Syntax error, insert ";" to complete BlockStatements
Copy linkTweet thisAlerts:
@FangApr 17.2010 — Afaik JavaScript can't access the session variables directly. Why not use cookies?
Copy linkTweet thisAlerts:
@padmaharikaauthorApr 17.2010 — well ..m new to javascript clould u just help me about telling me how to use cookies in java script so that i can retrive values from previous page
Copy linkTweet thisAlerts:
@MrRedApr 17.2010 — I was trying to do this and cookies would have been my next move but a different project hove into view. I still don't know how to use cookies properly. But it looks the way to co.

I did consider using the status line but that seems to be very iffy across the Browser spectrum. & I have been using it for adverts/date info for many years. see http://cresby.com
Copy linkTweet thisAlerts:
@padmaharikaauthorApr 17.2010 — thank will check that n let u knw if i cld succesfully do it
Copy linkTweet thisAlerts:
@padmaharikaauthorApr 17.2010 — hey i got it ...used ur first technique i.e by sending <%=(String)session.getAttribute("from")%> into the javascript function as a parameter .and ye i did altr the code a little ... called the functions directly from the body tag by onload.

Thank for all ur help ?
×

Success!

Help @padmaharika spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...