473,237 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

Dont have a clue anymore jsp to javascript

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 2032
Frinavale
9,735 Expert Mod 8TB
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...say for the file...but "loading the file" will still have to take place on the server.

-Frinny
Oct 1 '09 #2
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 Expert Mod 8TB
@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
Thanks Dormilich for your reply, i think i know enough to go forward with my project.
Oct 2 '09 #5
Dormilich
8,658 Expert Mod 8TB
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
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
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
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...
6
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...
7
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...
4
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...
5
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...
2
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.