LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-10-2007, 01:39 PM   #1
nkoplm
Member
 
Registered: May 2005
Distribution: Fedora
Posts: 92

Rep: Reputation: 15
jsp: passing a variable to an included file.


hello,

here is an example of my problem:
I have a file index.jsp, and within that file I have

<% String PageName = "Home"; %>
<jsp:include page="menu.jsp" />

Now I would like to have access to the PageName variable within menu.jsp so i can do things like

<%= PageName %>
in menu.jsp but as it stands now the variable is not passed to the included file.

how can i do this?
 
Old 06-12-2007, 11:27 AM   #2
hoodedmanwithsythe
Member
 
Registered: Apr 2006
Location: West Midlands, UK
Distribution: mandriva, centos, debian
Posts: 91

Rep: Reputation: 15
Quote:
Originally Posted by nkoplm
hello,

here is an example of my problem:
I have a file index.jsp, and within that file I have

<% String PageName = "Home"; %>
<jsp:include page="menu.jsp" />

Now I would like to have access to the PageName variable within menu.jsp so i can do things like

<%= PageName %>
in menu.jsp but as it stands now the variable is not passed to the included file.

how can i do this?
I don't know about the specific language that you are using as you haven't stated what is is.
but here's how we would do it in shell
Code:
include menu.jsp
export Page="Home"
by exporting the variable we make it possible for other apps or in this case pages to read it and use the variable.
if you give me the name of the programing language then mabey I can help a bit more by getting you the equivalent of the shell.
the only downside is that usually when you make a variable available to the other page or program is that it is also available to other programs that may be attempting to do something malicious and with web pages this can mean that hackers can exploit this.
but as i say I can probably find you a safe equivalent if you give me the name of the language that you are using.
Edit:
future note when asking for help state the language other wise it makes it very difficult for us to point you in the direction of someone who can help if the replier cannot.

Last edited by hoodedmanwithsythe; 06-12-2007 at 11:31 AM.
 
Old 06-12-2007, 02:37 PM   #3
nkoplm
Member
 
Registered: May 2005
Distribution: Fedora
Posts: 92

Original Poster
Rep: Reputation: 15
Sorry, I guess I was not clear enough. The language is JSP as stated in the title, and then 5 times in the message.

Last edited by nkoplm; 06-12-2007 at 02:39 PM.
 
Old 06-14-2007, 02:52 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Try the include directive instead of the include action:
Code:
<%@ include file="menu.jsp" %>
 
Old 06-15-2007, 08:07 AM   #5
hoodedmanwithsythe
Member
 
Registered: Apr 2006
Location: West Midlands, UK
Distribution: mandriva, centos, debian
Posts: 91

Rep: Reputation: 15
Sorry, I guess I was not clear enough. I don't do abbreviations if you had said JavaServer Pages I may have known which language you are on about jsp is not an abbreviation I would know about as I don't deal with web pages.

On the more helpful , friendly "I am here as someone to help!" side of things, that is not someone who is here to argue about little things I.E. what is a file extension/type and what is a language name.

Maybe you should try here.it looks relevant about mid page they use an import. and cover using frontends and backends to get things done in a professional manor.
I think it will help as they seem to do exactly what you are trying to do. however I have no knowledge of this language and so am uncertain if this is exactly the same but I am sure you will know when you see it if it is or not.

Last edited by hoodedmanwithsythe; 06-15-2007 at 08:11 AM. Reason: I forgot some quotations and an apostrophe
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
passing NameVirtualHost as a variable sunethj Linux - Server 5 05-15-2007 01:51 AM
[Ruby] Passing a variable to an email lmcilwain Programming 4 11-16-2006 08:05 PM
Passing a variable to a cgi script WindowBreaker Slackware 1 04-03-2006 10:02 PM
passing command output to variable Infernal211283 Linux - Newbie 12 01-11-2006 05:54 AM
passing passing variable in Java as reference djgerbavore Programming 3 11-10-2004 02:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration