473,396 Members | 1,766 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,396 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 2035
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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,...

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.