This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes Pass data to new JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Pass data to new JSP" Watch "Pass data to new JSP" New topic
Author

Pass data to new JSP

Andy Riegs
Greenhorn

Joined: Jul 23, 2013
Posts: 1
I have a JSP that retrieves JSON data from a remote server using a Java scriptlet.

<%
String url = "http://www,someurl.com/?apikey=xxx&find=searchstring";
URL jsonpage = new URL(urlStr);
URLConnection urlcon = jsonpage.openConnection();
BufferedReader buffread = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));
String jsonObj = buffread.readLine();
buffread.close();
%>

I parse the jsonOBJ, then dynamically create rows for an HTML table using Javascript for each partNo found in the search. Each table row shows only summary info...partNo, description, supplier. The partNo field is created as a link in one of the cells:

var a = document.createElement("a");
var url = "showDetails.jsp?" + partNo;
a.setAttribute("href", url);
a.appendChild(document.createTextNode(partNo));
var cell = row.insertCell(-1);
cell.appendChild(a);

I want to show the user the full details of the partNo on a separate HTML / JSP Page when clicked. So I tried passing the partNo to the new JSP as part of the url (see above), and then use AJAX to GET the info from the server again.

$.ajax({
url: "http://www,someurl.com/?apikey=xxx&find=partNo",
type: "get",
dataType: "json",
success: function(data) {
alert("Succes!");
},
error: function() {
alert("Fail!");
}
});

I'm getting the dreaded CORS error and JSONP format is not available from the remote server. What is the best way to show the details of the clicked partNo in a new JSP window?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass data to new JSP
 
Similar Threads
Problem with dojo.io.bind
using OGNL
How to read + operator using javascript
problem in json/ajax
Writing JSON data back to client