473,587 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

including JSP using javascript

Dear all,

I have a website where I need to fill its contents after retrieving
some data from another system (not a DB, but you can think like it).
I know the nature of the data, but the order that it is retrieved is
random, and there is no way to order it. Therefore, it is giving me
some pain to produce the html code.
I was thinking of having the following javascript to place my html
code. Here, "rightImg" is the ID of a DIV tag where I want to position
my code. The code should be the content of the htmlBody variable.

function addTopRightImag e() {
var htmlBody = '.';
if (document.all) {
document.all('r ightImg').inner HTML = htmlBody;
}
else if (document.getEl ementById) {
document.getEle mentById('right Img').innerHTML = htmlBody;
}

}

However, if I set the variable as it is shown bellow, the page is not
loaded as I want:

var htmlBody = '<jsp:include page="/WEB-INF/Standard.jsp"
flush="true"><j sp:param name="id" value="${myid}" /></jsp:include>';

Does anyone have a clue of what is going wrong? Maybe an alternative
solution?
Regards,
Pablo

Feb 22 '07 #1
1 14954
On Feb 22, 12:52 pm, "Pablo" <gom...@gmail.c omwrote:
Dear all,

I have a website where I need to fill its contents after retrieving
some data from another system (not a DB, but you can think like it).
I know the nature of the data, but the order that it is retrieved is
random, and there is no way to order it. Therefore, it is giving me
some pain to produce the html code.
I was thinking of having the following javascript to place my html
code. Here, "rightImg" is the ID of a DIV tag where I want to position
my code. The code should be the content of the htmlBody variable.

function addTopRightImag e() {
var htmlBody = '.';
if (document.all) {
document.all('r ightImg').inner HTML = htmlBody;
}
else if (document.getEl ementById) {
document.getEle mentById('right Img').innerHTML = htmlBody;
}

}

However, if I set the variable as it is shown bellow, the page is not
loaded as I want:

var htmlBody = '<jsp:include page="/WEB-INF/Standard.jsp"
flush="true"><j sp:param name="id" value="${myid}" /></jsp:include>';

Does anyone have a clue of what is going wrong? Maybe an alternative
solution?
Regards,
Pablo
Remember that javascript is executed on the client side, within the
browser (or other client device). JSP includes must be rendered on the
server (JSP is a server side technology). This idea will never work
for you... By the time the client is executing javascript, the server
has already done it's job and is waiting for the next request.

I've never experimented with it but you could possibly make an
XmlHTTPRequest for the jsp and be sent the processed result, and then
include it. But this is probably not at all they way you want to go
about this. Why can't the JSP do al the processing on the server side?
Is the "not a database" resource not available to the JSP?

Feb 22 '07 #2

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

Similar topics

2
1964
by: Theo | last post by:
Just a quick question... When including a page inside another (include('page.php')), is it bad for the second document to also have <head> and <body> tags etc? Im using iframes currently, and it works, but getting the page to match the content is kind of a javascript hack that only works after the page is loaded, not counting the images. So the new page loads, doesnt fit the old page size, and its changed. Not exactly fluid. Thx
4
1687
by: Berry B | last post by:
Hi! I'm extremely new to JavaScript programming, so bear with me pleace. I'm having trouble including a script into a page from an external .js file. I've put the following in the head; <script language="JavaScript" src="menu.js"></script> And in the body i've put the following: <BODY bgcolor="#000000" marginwirgin: 0" onLoad="printMenu()"
9
6124
by: Trenqo 0 | last post by:
I'm looking for a way to include javascript files from within a ".js" file. This would allow me to only need to link to one ".js" file, and yet still organize my functions into non gargantuan files for easy editing. I'm hoping there is some sort of include or import directive that I could use. Or if no such directive exists, I'm wondering if anyone has written one which I could use. I need to do this without any server side scripting....
3
1711
by: Joseph Ferris | last post by:
Hello everyone. I recently reloaded my system, and I am now having problems getting one of my client's sites running. I pulled a copy of the development tree for the project out of subVersion (the source control software we are using) and placed it into the IIS Web Root. After building and attempting to run the Solution, I am having problems with included Javascript files. How it is set up is that we have some .js files that have...
8
3653
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special character you can imagine. My question is this, how do I save an exact copy of the textarea...
3
1623
by: Mr. Roper | last post by:
I'm pretty weak when it comes to Java script, hopefully someone will take mercy on my sole and explain this to me. How come on the following HTML page, when I have my first script tag commented out, my button calls my OnClick function. However if I uncomment the first script tag, I get the following error: Button1_onclick is not defined <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">...
38
4000
by: Neo Geshel | last post by:
I am seeking a method to load one JS file directly into another, *without* having to dynamically write <scripttags. Is there any method whereby I can call only one external JS file using a single <scripttag, but have that external JS file insert into ITSELF the contents of five others? Something like: /*start external.js*/
10
2061
by: Robert Huff | last post by:
Can someone offer suggestions why, on the same server (Apache 2.2.8), this works <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en-US"> <head> <link rel=stylesheet type="text/css" href="proj_default.css" title="ss_default"> <title>Testing html</title> </head>
4
2451
by: r_ahimsa_m | last post by:
Hello, I am learning WWW technologies in Linux. I created index.html file which I can browse with Firefox/Konqueror using URL localhost/~robert/rozgloszenia/index.html. The page looks fine but there's one strange problem: I have written some JavaScript code in functions.js file which seems to be ignored when called although I have JavaScript enabled in Firefox/Konqueror. For example in functions.js I have:
1
1794
by: vunet | last post by:
What's the possible disadvantage of including JavaScript files within a JavaScript file? Why I needed it? For the sake of easy management, perhaps? Any load speed disadvantage? Example below: document.write('<script type="text/javascript" src="'+libraryName+'">< \/script>');
0
7924
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7978
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
8221
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...
1
5722
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
3845
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...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.