Passing a variable between html and jsp
Hello there,
I'm writing a simple application to show the use of custom tags. I have an html page with a dropdown box. Based on the selection from the dropdown box what the jsp outputs will be different. Can anyone tell me how to use the variable from the html page in the jsp page? The code is as follows:
manager.html <form method="post" action="manager.jsp">
<body>
<form>
<select name="person">
<option value="pevans">PEVANS
<option value="mgleeson">MGLEESON
<option value="jmolony">JMOLONY
<option value="pmccarthy">PMCCARTHY
<option value="jwalsh">JWALSH
</select>
<input type="submit" value="Submit" />
</form>
</body>
</form>and manager.jsp
<%@ taglib prefix="man" uri="/tags/weekdayTags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<table border="1">
<man:forEachLine manager="html selection" var="line">
<tr>
<c:forTokens items="${line}" delims="," var="field">
<td><c:out value="${field}"/></td>
</c:forTokens>
</tr>
</man:forEachLine>
</table>Thanks very much,
Ger
You need to use the response.getParameter("selectName") method which will return a String with the selected value.
Similar Messages
-
Can objects be passed between Applets and JSP?
Can objects be passed between Applets and JSP? If so how? Thanks in advance.
Scottsee if this helps,
http://forum.java.sun.com/thread.jsp?forum=54&thread=136847 -
Juggle between jstl and jsp!
I have a list of items and whose size is obtained by jstl as follows:
<c:set var="num" value="${fn:length(form.namesList)}"/>I have to find the number of blocks using jsp and I am trying as follows which is giving jspException.
<%int numCols = (int)Math.ceil( num / 10.0);%>Can anyone tell me the problem over here?
I need to use numCols to display my results using jstl as follows:
<c:forEach var="y" begin="${1}" end="${numCols }">
</c:forEach>Can juggle between jstl and jsp like this?This depends on the version of JSP you are using:
If you are using JSP 2.0 (like Tomcat 5), make sure you have downloaded and installed JSTL 1.1 and set the web.xml up to use the Servlet 2.4 specs. Then the code you wrote should work.
If you are using JSP 1.x (like Tomcat 4 and below), make sure you have JSTL 1.0. Then you can only use EL (the Expression Language used to translate ${...} expressions) inside JSTL.
If you want to use EL inside your custome tags, look through the Apache Jakarta sight. Somewhere they have an ELExpression translator (a couple of classes actually - whose full names I forget). These classes will let you take the ${...} expressions in as strings, pass them through the translators and get the correct objects back out.
Or you could go a simpler root:
<mob:whatever object="test" name="newname" />
then in your custom tag:
MyType test = (MyType)pageContext.findAttribute(object);
test.setName(name); -
Switching between Design and JSP tabs add code?
I am new to SJSC and I am taking the time to go through all of the little odds & ends of the IDE.
I was looking at:
http://blogs.sun.com/roller/page/tor?entry=computing_html_on_the_fly
And I decided to try this.
When I add the following in the JSP tab:
<h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>Save.
Then click on the Design tab, then go back to the JSP tab, I now have:
<h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>
<h:outputText binding="#{Page1.outputText1}" id="outputText1"/>It's late here, but this doesn't make any sense, why would switching between Design and JSP tabs add code?
Thanks,
--ToddGirish: I followed these steps:
1.) Downloaded:
Sun Java Studio Creator 2, Multilanguage creator-2-windows-ml.exe 254.23 MB
2.) When I started the install, I received the message:
Welcome to Sun Java(TM) Studio Creator 2! You are installing: Sun Java Studio Creator 2 development environment Sun Java System Application Server Platform Edition 8.1 2005Q1 Update Release 2 Bundled database
3.) Installed version:
Product Version: Java Studio Creator 2 (Build 060120)
IDE Versioning: IDE/1 spec=5.9.1.1 impl=060120
Also, Under, the Palette window: Standard component list, there is a component labeled Output Text.
When placed on a jsp, the following code is produced:
<h:outputText binding="#{Page1.outputText1}" id="outputText1" style="position: absolute; left: 24px; top: 48px"/>Thanks,
--Todd -
Propagation of ctx between EJB and JSP
Hello,
Does anybody know how to propagate the Security
Context between EJB and JSP so that when I login in my JSP page the user will be after recognized in my EJB system ?
Thanks
Francescotry this...as a test..
take a simple Contact ejb (as simple as you can make it, just a name and email address). In the ejb-jar.xml set up a role, for example, user, and restrict the access to only this role for all methods.
try to access the ejb from a jsp, and you should get the login form identified in your web.xml file.
make sure that the ejb is noted in the web.xml file, also.
this should work...
no try this...identify a role in your web.xml file, (user, for example) and restrict the access to the a particular jsp which is not calling the ejb. IF you navigate to this jsp, you should get the login prompt...
this should work....
now the tough part
in your application.xml create a role with the same name, user. By doing this, you have created a global role, and connect the two together.
Now point your browser to the restricted jsp with no calls to the ejb...you should get the login, so login in.
now navigate to your jsp which is unrestricted, but calls the restricted ejb...
there should now be no login prompt.
This should work. -
Difference between facelets and jsp xml in Document Type
I want difference between facelets and jsp in Document Type in JDeveloper 11gR2 (11.1.2)
Thanks
Edited by: Amr Ahmed on Jun 8, 2011 7:46 AMLet's see.
Facelets creates a facelets page
JSP creates a JSP page
{noformat}:){noformat}
Facelets is the "official" view language for JSF 2.0
http://www.realdevelopers.com/blog/development/facelets-vs-jsp should give you some more insight as well.
John -
How can I pass a variable between JSP and Role Form
I need to pass a variable from (a copy of) applicationmodify.jsp to the IDM Role Form so that the variable is available within the Role Form at display. We've tried getAttribute and setAttribute modifying both the Role Form and the applicationmodify JSP and can get the form to the role form but not accessible but have had no other success. Has anyone had any success in doing this? Any suggestions would be appreciated.
if by _root level you mean you're loading something into
_level0 you can't won't be able to use the localconnection. the
sharedobject is your only option. -
Hey,
Does anyone know how to pass a variable (string) from one swf
to another if there in separate html pages?
I assume I’d have to send the variable from the first
page and load it into the second but I don’t know what
functions or code I should be using. Any suggestions would be a
HUGE help.
Thanks
If it helps: I’m creating a log in and sign up sheet
that can be accessed from several sites. I’d like to record
which site the user has come from when they signup.
Thanksif they are open at the same time (for the same user), you
can use the localconnection class to communicate between the
two. -
How to pass a variable from HTML to Flash
I have built my flash ad banner in Flash 9 and now want the
HTML code to pass the url over to the flash movie that it should
jump to when clicked.
The info in the help file seems out of date for the latest
HTML template as it uses mainly JavaScript to get round IE's
dreadful embeding issue. So my problem is, how do I pass a variable
from the HTML to the actionScript specified int he Help file
(running on a full screen button) as shown below?
myButton_btn.onRelease = function() {
if (clickTAG.substr(0, 5) == "http:") {
getURL(clickTAG);
via the html code now used by Flash 9 which is like this:
<!-- saved from url=(0013)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Advert_long</title>
<script language="javascript"> AC_FL_RunContent = 0;
</script>
<script language="javascript"> DetectFlashVer = 0;
</script>
<script src="AC_RunActiveContent.js"
language="javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 115;
// -->
</script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!--
Coping
with
Growing
Audio
Series
Theraputic stories
for children aged
4 to 9
-->
<script language="JavaScript" type="text/javascript">
<!--
if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
var hasRightVersion = DetectFlashVer(requiredMajorVersion,
requiredMinorVersion, requiredRevision);
if(hasRightVersion) { // if we've detected an acceptable
version
// embed the flash movie
AC_FL_RunContent(
'codebase', '
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0',
'width', '120',
'height', '600',
'src', 'Advert_long',
'quality', 'high',
'pluginspage', '
http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'Advert_long',
'bgcolor', '#ffffff',
'name', 'Advert_long',
'menu', 'true',
'allowScriptAccess','sameDomain',
'allowFullScreen','false',
'movie', 'Advert_long',
'salign', ''
); //end AC code
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be
placed here.'
+ 'This content requires the Adobe Flash Player.'
+ '<a href=http://www.macromedia.com/go/getflash/>Get
Flash</a>';
document.write(alternateContent); // insert non-flash content
// -->
</script>
<noscript>
// Provide alternate content for browsers that do not support
scripting
// or for those that have scripting disabled.
Alternate HTML content should be placed here. This content
requires the Adobe Flash Player.
<a href="
http://www.macromedia.com/go/getflash/">Get
Flash</a>
</noscript>
</body>
</html>You should use SWFObject to embed your Flash. Not only does
it make
embedding more straightforward, it makes passing query
parameters very easy.
Check out:
http://code.google.com/p/swfobject/
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
How to pass a variable from HTML to Flash 9
I have built my flash ad banner in Flash 9 and now want the
HTML code to pass the url over to the flash movie that it should
jump to when clicked.
The info in the help file seems out of date for the latest
HTML template as it uses mainly JavaScript to get round IE's
dreadful embeding issue. So my problem is, how do I pass a variable
from the HTML to the actionScript specified int he Help file
(running on a full screen button) as shown below?
myButton_btn.onRelease = function() {
if (clickTAG.substr(0, 5) == "http:") {
getURL(clickTAG);
via the html code now used by Flash 9 which is like this:
<!-- saved from url=(0013)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Advert_long</title>
<script language="javascript"> AC_FL_RunContent = 0;
</script>
<script language="javascript"> DetectFlashVer = 0;
</script>
<script src="AC_RunActiveContent.js"
language="javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 115;
// -->
</script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!--
Coping
with
Growing
Audio
Series
Theraputic stories
for children aged
4 to 9
-->
<script language="JavaScript" type="text/javascript">
<!--
if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
var hasRightVersion = DetectFlashVer(requiredMajorVersion,
requiredMinorVersion, requiredRevision);
if(hasRightVersion) { // if we've detected an acceptable
version
// embed the flash movie
AC_FL_RunContent(
'codebase', '
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0',
'width', '120',
'height', '600',
'src', 'Advert_long',
'quality', 'high',
'pluginspage', '
http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'Advert_long',
'bgcolor', '#ffffff',
'name', 'Advert_long',
'menu', 'true',
'allowScriptAccess','sameDomain',
'allowFullScreen','false',
'movie', 'Advert_long',
'salign', ''
); //end AC code
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be
placed here.'
+ 'This content requires the Adobe Flash Player.'
+ '<a href=http://www.macromedia.com/go/getflash/>Get
Flash</a>';
document.write(alternateContent); // insert non-flash
content
// -->
</script>
<noscript>
// Provide alternate content for browsers that do not
support scripting
// or for those that have scripting disabled.
Alternate HTML content should be placed here. This content
requires the Adobe Flash Player.
<a href="
http://www.macromedia.com/go/getflash/">Get
Flash</a>
</noscript>
</body>
</html>You should use SWFObject to embed your Flash. Not only does
it make
embedding more straightforward, it makes passing query
parameters very easy.
Check out:
http://code.google.com/p/swfobject/
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
Passing dynamic variable from html to Flash
I know this is pretty simple but all that I have read doesn't make much sense to me. I have one swf calling another swf that I have embedded into an htnl. In other words just calling another html page in a seperate window.
In one.swf (runing in broswer) I use the below to call another html page passing the variable NewLessonArray. This contains an array of completed chapters.
// LOADING URL
var NewLessonCompleteArray:String = LessonCompleteArray.toString();
navigateToURL(new URLRequest("two/index.html?CurrentLessonInfo=<NewLessonCompleteArray>"), "_blank");
In the receiving swf I want to retrieve the passing parameters.
two.swf
// Getting the parameters passed
this.loaderInfo.parameters.toString()
All that is returned that I can see is object Object. But since I am passing on a address line into another swf embedded in a html page I am unable to determine that correct syntac for retrieving the information.
Any suggestions? This has got to be pretty simple... I think.
THANKSWhat you are trying to do is not extremely difficult to do, but it is not something I would consider as being simple. With Andrei's approach you should be able to take the url String and dissect the parameters from it using String methods, like split().
As for the loaderInfo end of things, you are not passing the parameters to the swf file, you are passing them to the html page. So the loaderInfo won't have any info for you regarding the url parameters. The loadInfo would typically get parameters via the FlashVars parameters passed in in the html's swf embedding code.
Here are some other solutions that you might consider. I have not dealt with these myself, they are merely in my collection of useful info, so you might have to experiment to get them working. One is a link to a class-based approach and the other is an approach that use swfObject embedding to dynamically add the parameters as FlashVars to the embedding code....
http://mikethenderson.com/2009/02/as3-return-query-string-value-version-2/#more-105
OR
In your HTML:
var flashvars = {};
if (swfobject.getQueryParamValue("aParameter")) {
flashvars.param = swfobject.getQueryParamValue("aParameter");
swfobject.embedSWF("myMovie.swf", "myContent", "550", "400", "9.0.0", "", flashvars);
And the param variable will be available as a FlashVar to your movie:
var theParam = loaderInfo.parameters.param; -
Passing a variable between applications
Hi,
I would like to pass a variable from a jsp page in a portal application into KM repository filter with user session context. For example, I will set { var1="sample data" } in the portal application and read it in the repository filter. Actually I am looking for a model like import/export statement in ABAP.
Thank you,
OrkunHi Orkun
Considering you aren't trying to send the variable in your url, you must concatenate your variable inside your well formed url and it must be considered during the iView configuration in your portal.
KM is able to get all posts from the client once you have informed first the name of variable that you are posting in your form.
There's no need to use session context at this point, we must consider session contexts when talking about statefull session beans. -
Pass parameter values between BEX and exctractor
Hi All,
I create virtual cube which report from ECC
I create Extractor Transformation and DTP which load the data from ECC
In the BEX I create parameter (Week day) which can get few values (E.g. 1,3,5)
In the extractor I define field for week day and need to consider the week days parameter
My question is how I pass the value between the BEX and extractor?
Thanks in advance
ItzikHi Itzik,
One simple solution,
Create a new IOB with Texts. In the Variable exit, write the variable values to this text IOB using FM RSNDI_MD_TEXTS_UPDATE.
Read the values from the IOB text using routine while selection.
Sankar Kumar -
Communicate large number of parameters and variables between Verstand and Labview Model
We have a dyno setup with a PXI-E chassis running Veristand 2014 and Inertia 2014. In order to enhance capabilities and timing of Veristand, I would like to use Labview models to perform tasks not possible by Veristand and Inertia. An example of this is to determine the maximum of a large number of thermocouples. Veristand has a compare funtion, but it compares only two values at a time. This makes for some lengthy and inflexible programming. Labview, on the other hand, has a function which aloows one to get the maximum of elements in an array in a single step. To use Labview I need to "send" the 50 or so thermocouples to the Labview model. In addition to the variables which need to be communicated between Veristand and Labview, I also need to present Labview with the threshold and confguration parameters. From the forums and user manuaIs understand that one has to use the connector pane in Labview and mapping in Veristand System Explorer to expose the inports and outports. The problem is that the Labview connector pane is limited to 27 I/O. How do I overcome that limitation?
BTW. I am fairly new to Labview and Versitand.
Thank you.
Richard
Solved!
Go to Solution.@Jarrod:
Thank you for the help. I created a simple test model and now understand how I can use clusters for a large number of variables. Regarding the mapping process: Can one map a folder of user channels to a cluster (one-step mapping)? Alternatively, I understand one can import a mapping (text) file in System Explorer. Is this import partial or does it replace all the mapping? The reason I am asking is that, if it is partial, then I can have separate mapping files for different configurations and my final mapping can be a combination of imported mapping files.
@SteveK:
Thank you for the hint on using a Custom Device. I understand that the Custom Device will be much more powerful and can be more generic. The problem at this stage is that my limitations in programming in Labview is far gretater than Labview models' limitations in Veristand. I'll definitely consider the Custom Device route once I am more provicient with LabView. Hopefully I'll be able to re-use some of the VI's I created for the LabView models.
Thanks
Richard -
Passing a variable between functions [Silly Question]
Hey, I am trying to write a program (who wouldve guessed) and I have the following problem. I set a variable in one function, but when I access it from another one, it is "undefined". How can I pass the variable, so both the functions see it? I thought the "public" class when defining a function should take care of that, but I was obviously wrong. Please help? (Code following...)
public function dalsi_slovicko():void {
var pocet_slovicek = slovnikXML.slovicka.elements("*").length();
var cislo_slovicka = randomNumber(0, pocet_slovicek);
var slovicko_1 = ask(cislo_slovicka, "en");
var slovicko_2 = ask(cislo_slovicka, "cs");
slovicko1.text = slovicko_1;
private function kontrola() : void {
if (nazor.text == slovicko_2) {
dalsi_slovicko()
else {
Alert.show("Špatně!! \n Slovicko_2 bylo:" + slovicko_2);
Thanks...create the variable outside the functions so it is accessible for all the functions.
private var slovicko_2;
public function dalsi_slovicko():void {
var pocet_slovicek = slovnikXML.slovicka.elements("*").length();
var cislo_slovicka = randomNumber(0, pocet_slovicek);
var slovicko_1 = ask(cislo_slovicka, "en");
slovicko_2 = ask(cislo_slovicka, "cs");
slovicko1.text = slovicko_1;
private function kontrola() : void {
if (nazor.text == slovicko_2) {
dalsi_slovicko()
else {
Alert.show("Špatně!! \n Slovicko_2 bylo:" + slovicko_2);
Also when you declare variables, set appropriate datatypes
Maybe you are looking for
-
We installed a C150 in our office and we enabled Message tracking on the day we installed the device. However when we try to find messages all the way back to October (the 13th, the day we installed it) there were no results found. At the top of the
-
Is there a way to find the Time Duration for applying a Patch?
Dear Legends, Is there a way to find the Installation or Applying time can be gauged for a PATCH, so that it will be useful to provide the DOWNTIME of the server. Thanks in Advance Regards, Karthik singh
-
Advaced Compression Limitations -- Based on no of columns
URGENT NEED - Would appreciate your help - Till date we worked on 10g where in our database is holding a partitioned table with less than 255 columns with each partition size of 70GB , and is being compressed and moved to history database ,we achieve
-
Ipad is frozen after attempting to download IOS upgrade. Wish i hadn't. Cannot turn off. What are the options?
-
Os 10.6.8 hung up after every boot
Hi My Imac os 10.6.8 hung up after every boot. It works well in Safe mode but in normal mode it gets hang after 2-3 minutes. Also the volume keys are not working and it is showing the cross mark and the headphone jack light is ON at the back. So plea