• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP include param - problems with multiple include from same page

 
Morten Frostie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there

I've stumbled upon a quite annoying problem, from which I at the moment know of no way to remedy..
Here goes:

I have two pages; PageA.jsp and PageAInclude.jsp

PageAInclude contains some visual html that I wish to embed two places on PageA.jsp, and I need a parameter sent in which will tell the included page how to operate and present itself.

Anyways, an example:


A simple example as you can see.
The problem however is that PageAInclude always writes out the same value from "myid".
In both includes, the value "1" is written out to the parent page PageA in both places where the include was placed, and not respectively "1" and "2" as I had anticipated.

Can anyone shed some light on this?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it should work ,in case of jsp:include ,if you want to get values in other end ,then

use String[] myID = request.getParameterValues();

String myID1 = myID[0]
String myID2 = myID[1]

Hope this helps
 
Morten Frostie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I know which array element to fetch in the included jsp?

Always assume the last element is the newest added, and thus the correct for the include "instance" at hand?

Like so:
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sorry!, i edit the message ,please see my above post once again
 
Morten Frostie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:hi sorry!, i edit the message ,please see my above post once again


So what are you actually saying? :-)
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Morten Frostie wrote:
So what are you actually saying?


As per your requirement ,what you are given code should work
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what's exactly up with the way that you are doing it, but a more modern approach would be to use tag files and to pass the variable as one of its attributes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!