473,652 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing the request attribute in the onLoad() event.

Hi,
I have cr8ed a javascript function in the head section of a jsp
page.

<!--
function go(theURL) {

alert(theURL);

if (theURL!=null){

window.open(the URL,'popup','sc rollbars=yes,re sizable=yes,wid th=800,h

eight=600');
}
}
//-->

This function receives a url and displays it in the pop up window.
This function is called by the onLoadevent() during the loading of the
page. The parameter passed is obtained using the request attribute in
the foll. manner.

<body text="#003366" onLoad="javascr ipt:go(
<%request.getPa rameter("val"); %>)" >

The alert() function in the javascript method display "unspecifie d"
message in this example.
However, accessing the request attribute and storing it in a string
gives me the required result.
ie. String url = <%request.getPa rameter("val"); %> gets the correct
url.

Just want to know if it is possible to use the request attribute
during the onLoad() event.

cheers



String name=request.ge tParameter("val ");

<a href="javascrip t:go('<%=url %>')">Click to view</a>

<jsp:forward page = "centre1.js p">

<jsp:param name = "val" value="<%= url %>"/>

</jsp:forward>

<%/*response.sendR edirect("centre 1.jsp");*/%>
Jul 23 '05 #1
9 28931
On 30 Sep 2004 03:58:43 -0700, Sunny <su************ @hotmail.com> wrote:
I have cr8ed
Is it really that difficult to type 'eat' instead of '8'?

[snip]
<!--
It's not necessary to hide scripts from browsers any more. Remove the
comment delimiters.

[snip] The parameter passed is obtained using the request attribute in
the foll. manner.
Wow! You've now saved a whopping six characters from your abbreviations.

Please write in full.
<body text="#003366" onLoad="javascr ipt:go(
<%request.getPa rameter("val"); %>)" >
The 'javascript:' prefix isn't needed. It's just a label in all but one
browser, and it doesn't matter even in that case most of the time. Remove
it.

[snip]
Just want to know if it is possible to use the request attribute
during the onLoad() event.


You seem to be confused as to what happens when. You don't use request in
a load event. By the time the client sees the page, the server has
substituted the code for a value of some kind, and that is what's used.

This is why showing server-side code is useless. It doesn't actually show
the problem because it has no bearing on client-side execution. It's the
values that *result* from the server-side code that matter.

I suspect that the problem is simply an unquoted value. I haven't used
JSP, but I assume that the code above returns an unquoted string, correct?
If so, just place a single quote before the <% and another after the %>.
If that doesn't help, post what you get when you view the source in the
browser.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Hi,

In article <opse428pr2x13k vk@atlantis>, Michael Winter wrote:
On 30 Sep 2004 03:58:43 -0700, Sunny <su************ @hotmail.com> wrote:

<!--


It's not necessary to hide scripts from browsers any more. Remove the
comment delimiters.


It's useful though, since some site-search engines are prevented to index
script blocks through this. A good example is PHPdig.

Ranbir
Jul 23 '05 #3
On Thu, 30 Sep 2004 14:27:37 +0200, Ranbir Kaur <sm****@yahoo.c om> wrote:

[snip]
It's not necessary to hide scripts from browsers any more. Remove the
comment delimiters.


It's useful though, since some site-search engines are prevented to
index script blocks through this. A good example is PHPdig.


In that case, do what you probably should be doing, anyway. Move the
script into an external file.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4
Sunny wrote:
This function receives a url and displays it in the pop up window.
No, that may be what you intend it to do. However, in a lot of browsers it won't do
anything except possibly warn the user a Web page tried to open a new window and the
attempt was captured and suppressed. This list of browsers includes, but isn't
limited to:

IE < 6.0.2900 with the google toolbar, the newest AIM w/popup blocker installed or
any other popup blocker (Window Washer, some Symantec software, Proxomitron, etc)
IE 6.0.2900 in it's default configuration
Any Gecko-based browser (Mozilla, Netscape, Firefox, Camino) in it's default
configuration
Opera 7.54 if configured to "Block unwanted pop-ups" (I haven't bothered to check,
but I'd bet it will start coming configured that way in 7.6)

All these browsers and browser add-ons come with this option because people are sick
of new windows popping up simple because they chose to visit a Web site.

Of course, if this is for an Intranet application, and you control the browsers
used, and their configuration, then by all means continue to open a new window on
page load.
Just want to know if it is possible to use the request attribute
during the onLoad() event.


Sure you can use a server-side request in an onload event:

<% String val = request.getPara meter("val"); %>
<body onload="alert(' <%= val %>');">

As some others have said, it's most likely that you didn't quote the string that
gets returned from request.getPara meter(). In other words, you're doing this:

<% String val = request.getPara meter("val"); %>
<body onload="alert(< %= val %>);">

(note the missing inner single quotation marks on the call to alert())

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #5
Sorry, but at the end of the day, typing full words (when one can do
with abbreviations and get the message across)is the last thing on my
mind. hehehehehe!!!!

Aneways, When i use <body text="#003366" onLoad="javascr ipt:go(
'<%request.getP arameter("val") ;%>')" >

the source in the browser is
<body text = "#003366" onLoad = "javascript:go( '')" >

and it shows an empty alert box. It also goes on to pop up an empty
window.

<%
String name=request.ge tParameter("val ");
out.println("ur l= "+name);
%>
Using the above statement in the jsp body does return me a proper url
which is printed on the same page.

cheers
Sunil

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #6

oops, did not use the '=' in <%=....%>. got tht working now.

Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #7
On 30 Sep 2004 23:29:59 GMT, Sunil Kamath <su************ @yahoo.com> wrote:

[snip]
the source in the browser is
<body text = "#003366" onLoad = "javascript:go( '')" >
and it shows an empty alert box. It also goes on to pop up an empty
window.

<%
String name=request.ge tParameter("val ");
out.println("ur l= "+name);
%>
Using the above statement in the jsp body does return me a proper url
which is printed on the same page.


Then your problem must be on the server, and not with Javascript.

Ask in the JSP forum on Sun's website. I also believe JSP is on-topic in
one (or possibly more) of the comp.lang.java. * groups.

Good luck,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #8
Lee
Sunil Kamath said:

Sorry, but at the end of the day, typing full words (when one can do
with abbreviations and get the message across)is the last thing on my
mind. hehehehehe!!!!


You're asking people to help you.
You owe them the courtesy of making your post as easy to read as possible.

Jul 23 '05 #9
Ranbir Kaur wrote:
In article <opse428pr2x13k vk@atlantis>, Michael Winter wrote:
On 30 Sep 2004 03:58:43 -0700, Sunny <su************ @hotmail.com> wrote:
> <!--


It's not necessary to hide scripts from browsers any more. Remove the
comment delimiters.


It's useful though, since some site-search engines are prevented to index
script blocks through this. A good example is PHPdig.


Then this app(s) is/are b0rken. It/They should not index script elements
at all (or at least should provide a pref to do so), whether "commented out"
or not.
PointedEars
--
Clarity of thought before rashness of action.
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9664
by: Mike Hnatt | last post by:
I'd like the focus to be on "mycontrol" when the page is first loaded. I'm getting an undefined error and am assuming that I can't do this in the body ONLOAD event because the control is not yet rendered. (but I thought this would still work) <body onload="mycontrol.focus()"> Also, is there a way to not produce an error if that control does not exist? Thanks!
2
6203
by: Bender | last post by:
Hi, I am wanting to capture an onmousedown event without firing the body tags onload event. Also, if anyone could explain why this happens that would be excellent. I can't see how an onmousedown event could bubble up to an onload event. NOTE: If you put an alert() statement in the onmousedown event handler the body onload event doesn't get fired.
4
4906
by: Pai | last post by:
hello there, I am trying to rersize the window it works find in IE but doea not work with mozilla window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello'); window.resizeTo(810,750); top.outerWidth=810;
6
4560
by: Brian | last post by:
Hi everyone, I'm writing a function (in javascript) that needs to do one thing if the page has not loaded, and another (different) thing if the page has already loaded. I'm looking for a way to tell if the window.onload event has already fired. I cannot edit the onload event handler itself, and my function can only exist in an external js file, sourced from the document's head section. Any ideas?
1
10197
by: Adam Ratcliffe | last post by:
I'm trying to come up with a solution for detecting when an image, loaded by a script, has completely loaded. The Image.onload event is fired after the image has loaded in Firefox but before loading has completed in Internet Explorer. The function where I assign the onload event handler looks like this: var newImage = new Image(); function getImage(url) { var image = document.getElementById("theImg");
5
2774
by: Andy Fish | last post by:
Hi, I have an asp.net web application which uses a pop-up form that works a bit like a dialog box. when the user clicks "OK" it does a postback (basically a form post if you don't know .net) to save the contents of the form, and then I put an onload event to do a window.close. this works fine for hundreds of people on different browsers. However, for one user the window does not close.
6
9554
by: pronerd | last post by:
Hi, I am trying to dynamically set an event handler across frames. I have no problems setting properties across frames doing something like parent.ToolMenuFrame.location.href = 'http://www.blah blah blah.com'; But when I try to set an event handler this way, as shown below, it fails. parent.ToolMenuFrame.window.document.body.onload = "alert('On Load Trigger Fired!!');"; parent.ToolMenuFrame.document.body.onload = "alert('On Load...
6
19253
by: Daz | last post by:
Hello everyone, I would like to open a child window from the parent, and add an onload event listener to the child window which will tell the parent when the document has loaded. As far as I know, this shouldn't be an issue, but I just can't get it to work. The script only needs to work with Firefox/Mozilla, so XP code isn't an issue. I have tried to open a window like so.
1
2128
by: webgour | last post by:
Hello, I would like to create an onload event within my object. The following works fine : function TEST() { this.image= new Image(); } TEST.prototype.Initialize = function()
1
8467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.