Solved

Using the session to pass variables from PHP to JSP

Posted on 2014-09-23
4
880 Views
Last Modified: 2014-09-29
In some php code I store a variable with

$_SESSION['art']=$art;
Art is an array variable with file names in column 1.

How do I retrieve the variable with jsp

art = session.getAttribute("$art");

Seems to die and no output is generated.
0
Comment
Question by:padmasambhava
  • 2
4 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40340098
Let me suggest a slightly different approach, since these two server languages are not designed to share the session variables.  You can exchange this information with an API that sits in both languages.  I would recommend that you have a class with get() and put() methods.  For the put() method, in each language, you feed the class a JSON string representing the session values you want to store.  The put() will either create or overwrite the session values.  For the get() method, the session values (JSON string) are returned.  There is some extra programming needed for this to work, but that's usually the case when you have to make two different engines talk to each other.
0
 
LVL 27

Expert Comment

by:rrz
ID: 40340241
You could send a request from your PHP to your JSP. The URL could look something like  
http://<host>/<context>/test.jsp?art=$art      
in  test.jsp  use  
<% 
   String art = request.getParameter("art");
%>
art is <%=art%>

Open in new window

or simply use  
art is ${param.art}

Open in new window

0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40351299
Thanks for the points -- it's a great question, ~Ray
0
 

Author Comment

by:padmasambhava
ID: 40351311
Somehow I kinda wish I wasn't so good at generating "good" questions. LoL

Also I realized I can pass all of my array in less than 1500 bytes so no coding summer salts.

Thanks for all your help Ray.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

749 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