473,624 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dont have a clue anymore jsp to javascript

3 New Member
Hi everyone,
I hope there is somebody that can help me.

I normally am programming in jsp or java, but i now have to program in javascript. I hope somebody can help me or get me in too the right direction.

normally when iam using jsp i would add these codes.

when i click on a link it will send the string blablabla of the parameter p

Expand|Select|Wrap|Line Numbers
  1. <a href="?p=blablabla&id="
  2.  
the string of the parameter p will be set to the string p

Expand|Select|Wrap|Line Numbers
  1. String p = request.getParameter("p");
  2. String id = request.getParameter("id");
  3. String img = request.getParameter("img");
  4. p = p != null ? p : "";
  5.  
after that the string p will be used to get a file loaded inside a div (everytime when i click on another link it will send that string and will load the page inside the div.

Expand|Select|Wrap|Line Numbers
  1. String includeDir = "/content";
  2.  
  3. if (p.length() > 0 && new File(request.getRealPath(includeDir + "/" + p + ".jsp")).exists())
  4. {
  5.           pageContext.include(includeDir + "/" + p + ".jsp");
  6. }
  7. else if (p.length() > 0 && new File(request.getRealPath(includeDir + "/" + p)).exists())
  8. {
  9.           pageContext.include(includeDir + "/" + p);
  10. }
  11. else
  12. {
  13. pageContext.include(includeDir + "/" + "home.jsp");
  14. }    
  15.  
  16.  

now is my question how can i do this kind of thing in javascript. Is it even possible. Could you give me an example or what kind of things i need to use or where to look. I can also send the whole jsp document if its easier to help.

(the thing is what i want. When i click on a link, i want that the content of multiple div's are changed depending on the parameter that the link sends.
i.e. one div must load a html file with txt. and one div must load a picture. and in one div the txt must be changed)

thanks in advance.

Greetings
Martin Janssen
Oct 1 '09 #1
5 2041
Frinavale
9,735 Recognized Expert Moderator Expert
I'm not sure that JavaScript is the best tool to solve your problem.

JavaScript runs client-side (in the web browser). It doesn't do anything on the server at all.

If you need to load a file into a <div> then you're going to have to use server-side (jsp) code.

You could use Ajax (which is just a fancy form of JavaScript, it stands for Asynchronous JavaScript and XML) to make a request to the web server for some information...s ay for the file...but "loading the file" will still have to take place on the server.

-Frinny
Oct 1 '09 #2
DrMalik
3 New Member
Thanks Frinavale for your answer.

I only have one question, is it possible with javascript:

when i click on a link, that it send a string of the parameter p

i also have a div named content within that div i have a if. else if statement.

i want the string send and with the string i check if it's true inside the if.else if statement. it will then show the things that are inside the if or else if or else statement.

can this be done and how should i do it or where should i look to do this.

thanks in advance.

greetings,
Martin janssen
Oct 2 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
@DrMalik
possible. if you want to follow the link, you don’t even need JavaScript, otherwise you have to use AJAX. and if you use AJAX, it doesn’t need to be a link (it will work with any element).

@DrMalik
this can be done (AJAX again) but I strongly recommend doing this on the server (JSP, PHP, …), since JavaScript can be turned off.
Oct 2 '09 #4
DrMalik
3 New Member
Thanks Dormilich for your reply, i think i know enough to go forward with my project.
Oct 2 '09 #5
Dormilich
8,658 Recognized Expert Moderator Expert
I’m glad to be of help.
Oct 2 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3571
by: ChronicFatigue | last post by:
Given that some browsers dont have javascript enabled.... do developers try to avoid using javascript when a php alternative can be used? What sort of alternative php scripts are often used?
19
2889
by: Wouter | last post by:
Hi, I try to make when i send a <form> that he dont open a new window. Is there someone who know how i can make this whit javascript ? Greets Wouter
24
7658
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my Dispose-Method and call the GC nothing happend!!! my Disposemethod has never been called!! so the GC dont call my Dispose-Method although I implemented IDisposable? what am i doing wrong?
6
1511
by: Benjamin Bittner | last post by:
Hallo NG, ive found this script http://www.iisfaq.com/default.aspx?View=A399&P=109. Now i want to use that script in a web application. can someone plz help me to convert it, or show me a way to call it from asp.net (written in vb.net). thx in advance regards benjamin
7
1367
by: Maarten | last post by:
Hi, I have a gridview (2.0), in the page load I remove a couple of columns from the gridview which I dont need. (All the columns are databound) This works fine. But after a postback all the templatefields are not bind anymore. Only the boundfields are still bound. Why? and what can I do about this?
4
1421
by: windandwaves | last post by:
Hi Folk Can you please have a look at http://www.friars.co.nz/map.php and let me know if the map is working on IE6 (just do a simple search). Unfortunately, I do not have IE6 anymore and so I can not test it. I think there maybe some trouble with retrieving the AJAX xml. Below is the code for this: var i = new Array();
5
3465
by: -Lost | last post by:
Error: uncaught exception: " nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: file:///D:/sites/_test/js/iterate_document.htm :: <TOP_LEVEL:: line 15" data: no] Line 15 being: s += j + ". " + i + ": " + document + "<br />\n"; All the code:
2
2566
by: romain.larmet | last post by:
Hi all, I need to get the mouse cursor's position using JavaScript. Until now, everything was working well in IE, FF and Opera using the event.clientX/Y and e.pageX/Y members, depending on which browser is used. However, I've made some modifications (I don't remember what precisely but nothing related to this component, in fact) and now this portion of JavaScript code isn't working anymore. Now, the cursor's position are still...
0
8182
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
8688
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...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8494
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
6115
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
5570
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
4085
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
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1496
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.