Solved

Hiting a url inside a jsp

Posted on 2014-03-11
7
465 Views
Last Modified: 2014-03-27
HI,
I want to fire a url from inside a jsp.
How do i do it.

Also in the following function :
function hitInternalTrackerSystem(){
	var prmstr = window.location.search.substr(1);
	var prmarr = prmstr.split ("&");
	var params = {};

	for ( var i = 0; i < prmarr.length; i++) {
	    var tmparr = prmarr[i].split("=");
	    params[tmparr[0]] = tmparr[1];
	}
	if(params.ci){
		//hit the url
		var image = new Image(1,1);
		<c:out value="${applicationScope.affilatePrefix}" />
		<c:out value="hi hih ihii" />
		image.src= "${applicationScope.affilatePrefix}" + "/flights-aff-tracking/Tracker?ci="+params.ci;
		<img src=image.src />
	}
	
}

Open in new window


The img tag is not working.
That is if i view the source
the image.src variable value is not getting picked up
It shows as <img src=image.src />

Thanks
0
Comment
Question by:Rohit Bajaj
  • 4
  • 3
7 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 500 total points
Comment Utility
window.location.href="${applicationScope.affilatePrefix}" + "/flights-aff-tracking/Tracker?ci="+params.ci;
0
 

Author Comment

by:Rohit Bajaj
Comment Utility
Hi,
I tried above but it didnt work. Probably there is a mistake at my end.

function hitInternalTrackerSystem(){
	var prmstr = window.location.search.substr(1);
	var prmarr = prmstr.split ("&");
	var params = {};

	for ( var i = 0; i < prmarr.length; i++) {
	    var tmparr = prmarr[i].split("=");
	    params[tmparr[0]] = tmparr[1];
	}
	var string = "rock";
	<c:out value='string' />
	<c:out value="${params.ci}" />
	if(params.ci){
		//hit the url
		var image = new Image(1,1);
		<c:out value="${params.ci}" />
		window.location.href="${applicationScope.affilatePrefix}" + "/flights-aff-tracking/Tracker?ci="+params.ci;
		
	}
	
}

Open in new window


I tried the above code.
Probably its nor firing because the condition if(params.ci) is not holding true.

I tried c:out the value but its not working.
Please help me in how do i debug this.

How to c:out the value of the variable params.ci

Is there any other way i can debug jsp using eclipse ?
0
 

Author Comment

by:Rohit Bajaj
Comment Utility
The above code is inside a <script> tag. On debuggin with firebug i found it is indeed empty.

What i am trying to achive is the following.
I am hitting my Java spring App with url http://localhost:8080/mobile/?ci=vizury
Now i need this string "vizury" in a parameter in my jsp .
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:Rohit Bajaj
Comment Utility
Hi,
I somewhat sorted out the issue at my end.
But your code :window.location.href="${applicationScope.affilatePrefix}" + "/flights-aff-tracking/Tracker?ci="+params.ci;

Redirects me to this url.
I dont want to redirect to this url. But just hit it and stay on the same page
0
 
LVL 20

Expert Comment

by:chaitu chaitu
Comment Utility
what do you want to do after you want to fire a url?intiailly i thought to redirecting the url to another page.

if you stay on the same page user ajax-jquery combination in the javascript..

check these examples

https://api.jquery.com/jQuery.post/
0
 

Author Comment

by:Rohit Bajaj
Comment Utility
That url is actually calling another webapp deployed on local which will set a cookie.
0
 
LVL 20

Expert Comment

by:chaitu chaitu
Comment Utility
have you checkd the examples that i posted on ajax,jquery
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now