Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using the session to pass variables from PHP to JSP

Posted on 2014-09-23
4
Medium Priority
?
1,023 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 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 28

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 111

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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