Passing parameter between jsp pages
Hi
I'v got the following problem: I have an jsp page that shows result of sql query as a list of 5 items, if there are more items returned - it shows first five, user is able to see more by clicking to a link which shows him the same page with next 5 items etc. The piece of index.jsp file with that link looks like that:
<html:link action="<%=(String)request.getAttribute("actionMod")%> module=... name=... styleClass=...>and at the end of initSearchAction I have:
req.setAttribute("actionMod","initSearch.do");Action is defined:
<!-- action for product list -->
<action path="/initSearch"
type="...list.InitSearchAction"
name="productListForm"
validate="false"
scope="request"
unknown="false"
>
<forward name="success" path=".search"/>
</action> .search is defined as
<definition name=".search" extends=".main">
<put name="body" value="/list/index.jsp" />
</definition>The problem is when I set a paramter in initSearchAction like that:
req.setAttribute("handle",h);and try to read it next time when initSearchAction action is running, parameter h is null. I need that to pass handle to stateful session bean that holds important information that need to be static during a session. Can anyone tell me how to pass that handle in some other way?
regards
ania
now it works :)
I'm new to this things so I'm not familiar with all those sessions and requests...
thanks a lot
ania
Similar Messages
-
Urgent! pass parameters between jsp pages
Does anyone can give an example about how to pass parameters between jsp pages?
This is what I do:
pageContext.forward("pag_loginc.jsp?p_idusr=" + strUsr + "&c_password=");
But when deployed is not working.
Help is needed.can you put that stuff in the session context in the first page, then pull it out in the second page?
-
Pass parameter between uix page
Hi, I am new to JDeveloper UIX technologies. I have created two uix page: page1 is built on a view. Page2 is on a table. How do I pass a parameter (customer_id) from page1 to page2?
Any help is appreciated. Thanks ahead!You can get the sample code for your answer here:
http://otn.oracle.com/sample_code/products/jdev/index.html
Download sample code with title:
Passing values between pages
Or alternatively your can keep the customer_id in the session during ActionForward then passing back the value into a textbox in page 2.
Code in ActionForward:
request.getSession().setAttribute("customer_id", value);
Code in UIX Page 2:
<textInput text="${sessionScope.customer_id}" name="code2"/>
Thanks.
Alex Cheong -
I would like to pass values between pages.
I don't want showing up on the url. Ex: some.jsp?param=value
I don't feel it's safe.
It's not coming from form either....
How can I hide the value and pass it to next page?
I want to pass the value when the user click on a hyperlink
Thanks In Advance.
Message was edited by:
TheepanClient side information is never safe no matter what you do. If the values don't end up in the url, they are always present SOMEWHERE in the html content.
If you don't want the values to end up in the url, rework the page so it DOES do a post form submit. You could turn the hyperlink into a javascript call that submits the form for you. -
To pass value between jsp page
How can I pass hidden's value from a jsp page to other?
My code is:
a.jsp
<h:form id="insUser">
<h:inputHidden id="flag" value="1"></h:inputHidden>
</h:form>
b.jsp
<%String flag="";
flag=request.getParameter("flag");
out.print("flag="+flag);
%>
b.jsp shows: flag=null
Could you help me?Because this hidden field id is insUser:flag, but not just flag.
If you have subview or other naming container(s) around form, the id name might be even longer.
Sergey : https://ajax4jsf.dev.java.net/ -
Passing values between jsp pages
Hi all,
I am a newbie to jsp. I am trying to pass value from one jsp to another.
Let me post the code here and make my point clear. I have 3 jsp pages and am trying to get the value into my 3rd page that was in the first page.
This is my Test.jsp page:
<%@page contentType="text/html"%>
<html>
<head><title>Test JSP Page</title></head>
<body>
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
Testing.. JSP Page
<FORM action='Response.jsp' method="POST">
<input type='Text' name='get_name'>
<input type="submit" value="Click Me">
</FORM>
</body>
</html>
This is my response.jsp page:
<%@page contentType="text/html"%>
<%@page import = "sun.jdbc.rowset.CachedRowSet" %>
<html>
<head><title>Response Page</title></head>
<body>
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
Thank you... <%=request.getParameter("get_name") %>
// I want to pass this get_name to my next page, but since request.getParameter returns an object and not a string, how will I capture the value and pass it to my next page.
</body>
</html>
The 3rd jsp page is:
<%@page contentType="text/html"%>
<html>
<head><title>JSP Page</title></head>
<body>
// I am trying to get the value of the name here in this page.
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
</body>
</html>
Your help is appreciated.
ThanksHi,
Thanks for the reply, it works. I was wondering whether this is an efficient way of doing this. What I want to do further is to setup a connection to a database and use the value I got from my previous page to query the DB and get the results and display.
I have see some code in the java website and a lot of people do by writting a bean /class(believe bean is just a class) and then importing it and do the things that way. I have good knowledge of OO and Java as a language and would definitely love to do it this way.
What i think i am missing is the basic idea to doing this way. So if you could let me know how to do this using java classes I would really appreciate it. If its too much to explain can u point to some good source(URL's) that explain's this. I have searched on this and all i find is code with no good explaination.
Thanks a lot -
Admin1.jsp
In this jsp page i have a drop down list with<select name=Update
From this page i move to the page Adnim2.jsp
Admin2.jsp
In this page i request for the value of selected entry in the drop down list as follows
String a=request.getParameter("Update");
From this page i move onto a servlet UpdateContribution.java
UpdateContribution.java
Here i need the value of the selected entry in drop down list ie Update
but String a=request.getParameter("Update"); does not work here and i get a Null Pointer Exception
Please help meIn Admin2.jsp, add a hidden form field and assign the selected value of drop-down to it. Now, you can obtain
the selected value of drop-down in Servlet(UpdateContribution.java) using given hidden form field.
Or,
Store the selected value of drop-down list in session. Now, you can obtain the value in servlet(UpdateContribution.java) through session -
ADF Passing parameter between 2 Page Fragments
Hi,
I have One Bounded task flow. Inside there are 2 page framgments.
1)Header Page Pragment has table
I changed table column itemId to af:commandLink to navigate to next detail page.
<af:column sortProperty="ItemId" sortable="false"
headerText="#{bindings.XxTestStgVO1.hints.ItemId.label}"
id="c4">
<af:commandLink id="ot3" text="#{row.ItemId}"
action="select">
<af:setPropertyListener from="#{row.ItemId}"
to="#{pageFlowScope.pfsItemId}"
type="action"/>
</af:commandLink>
</af:column>While navigating to detail page we are using ExecuteWithParameters.
<action IterBinding="FilesByItemParam1Iterator" id="ExecuteWithParams"
RequiresUpdateModel="true" Action="executeWithParams">
<NamedData NDName="p_item_id" NDValue="#{pageFlowScope.pfsItemId}"
NDType="java.lang.String"/>
</action>However click on Command Linkon header Table is not working.
I followed steps as in
http://www.youtube.com/watch?v=4eyzBiIf5MM
Did i miss anything ? or is there any Property needs to be changed ?
Thanks,
JitHi,
Source Master Page
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:pageTemplate viewId="/oracle/templates/threeColumnTemplate.jspx"
id="pt1">
<f:facet name="center">
<af:table value="#{bindings.XxTestStgVO1.collectionModel}" var="row"
rows="#{bindings.XxTestStgVO1.rangeSize}"
emptyText="#{bindings.XxTestStgVO1.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.XxTestStgVO1.rangeSize}"
rowBandingInterval="0"
filterModel="#{bindings.XxTestStgVO1Query.queryDescriptor}"
queryListener="#{bindings.XxTestStgVO1Query.processQuery}"
filterVisible="true" varStatus="vs"
selectedRowKeys="#{bindings.XxTestStgVO1.collectionModel.selectedRow}"
selectionListener="#{bindings.XxTestStgVO1.collectionModel.makeCurrent}"
rowSelection="single" id="t1">
<af:column sortProperty="ItemId" filterable="true" sortable="true"
headerText="#{bindings.XxTestStgVO1.hints.ItemId.label}"
id="c1">
<af:commandLink id="ot4" text="#{row.ItemId}" action="select"
partialSubmit="true">
<af:setPropertyListener from="#{row.ItemId}"
to="#{pageFlowScope.pfsItemId}"
type="action"/>
</af:commandLink>
</af:column>
<af:column sortProperty="ItemNumber" filterable="true"
sortable="true"
headerText="#{bindings.XxTestStgVO1.hints.ItemNumber.label}"
id="c2">
<af:outputText value="#{row.ItemNumber}" id="ot3"/>
</af:column>
<af:column sortProperty="RequestId" filterable="true"
sortable="true"
headerText="#{bindings.XxTestStgVO1.hints.RequestId.label}"
id="c3">
<af:outputText value="#{row.RequestId}" id="ot2">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.XxTestStgVO1.hints.RequestId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="StatusId" filterable="true"
sortable="true"
headerText="#{bindings.XxTestStgVO1.hints.StatusId.label}"
id="c4">
<af:outputText value="#{row.StatusId}" id="ot1"/>
</af:column>
</af:table>
</f:facet>
<f:facet name="header"/>
<f:facet name="branding"/>
<f:facet name="copyright"/>
<f:facet name="status"/>
</af:pageTemplate>
</af:form>
</af:document>
</f:view>
</jsp:root>Target Page
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:form id="f1">
<af:pageTemplate viewId="/oracle/templates/threeColumnTemplate.jspx"
id="pt1">
<f:facet name="center">
<af:outputText value="#{pageFlowScope.pfsItemId}" id="ot1"/>
</f:facet>
<f:facet name="header"/>
<f:facet name="end"/>
<f:facet name="start"/>
<f:facet name="branding"/>
<f:facet name="copyright"/>
<f:facet name="status"/>
</af:pageTemplate>
</af:form>
</af:document>
</f:view>
</jsp:root>Appreciate your help.
Jit -
Passing parameter between OAF pages
Hi,
Im calling a custom page from a button destination URI property.
OA.jsp?page=/oracle/apps/ont/orderstatus/webui/INT_SUMM_PAGE&HeaderId={!HeaderId}&retainAM=Y&addBreadCrumb=Y
When I use {!HeaderId}, null value is passed
When I use {@HeaderId}, '@HeaderId' is passed as such.
What is the difference between two formats?When you specify URL parameters in your declarative page definitions, you can specify both literal and token-substituted values that obtain their data from associated view object attributes at rendering time
{!Attr} - encrypts the attribute value while leaving the {!} in the URL (for example, OA.jsp?...&ssn={!SSN}&...). Using OAPageContext.getParameter("ssn") will return the decrypted value.
{@Attr} - encodes the attribute value while leaving the {@} in the URL (for example, OA.jsp?...&addr={@EmpAdd}&...). Using OAPageContext.getParameter("addr") to get the parameter value will return the decoded value.
--Shiv -
Passing parameter between JSF pages
I need to pass a parameter value between 2 different JSF pages.
The reason I need to do this is to be able to know which JavaBean (A or B) called the other JavaBean (C).
Can I somehow set a parameter within the JSF page and retrieve it in the second JSF page for my backing bean to read?
Thanks in advance.A co-worker of mine helped me fix my code to make it work!
Here is the final solution in case someone else needs to do the same thing in the future:
In the main JSF page that calls the second JSF page, the following code was added at the beginning of the page in the JavaScript section:
<% session.setAttribute"className", "CcmReassignEmployeeBean");
And in the Backing Bean of the second JSF page, the following code was used in the action listener used to transfer the data:
HttpSession session = (HttpSession) context.getExternalContext().getSession(true);
String className=(String) session.getAttribute("className");
It works great! Thanks! -
Jsf passing parameter between jsp's
Hi
I have my main.jsp and another screen which i call object.jsp
the object.jsp can present an object in multiple ways : add, edit, view
i have 3 buttons in my main.jsp add, edit, view. I want to pass a parameter from main.jsp to object.jsp such that object.jsp will know in what state its being loaded... how do i do this?
Thanks..session?
as the article says :
To avoid these problems, developers might use session-scoped variables instead. This fixes both of those problems, but adds new ones:
A single user cannot have two windows open simultaneously; session-scoped variables are global to the user. So, for instance, a user could not work with two different search results simultaneously.
Back button support is highly limited, since navigating back can't magically restore the session to its old state. -
Hi All,
I want to pass a parameter (let us say data from a text box) from one JSP to another on an event (when 'Submit' button is clicked.). Can you please let me know how to go about this? Any sample codes or any other kind of help will be greatly appriciated.
Thanks in advance.hi,
It's quite easy, just go thru the following code.
one.jsp
<form action="two.jsp" method="post">
<input type="text" name="name"/>
<input type="submit" value="Press"/>
</form>now receive the value in two.jsp and print the same.
two.jsp
<%
String name=request.getParameter("name");
out.print("Your Name -->"+name);
%>Bala -
Hi!,
I need a suggestion to this problem that i'm facing.I want to traverse between JSP pages which follow like a wizard.i.e,i click next to go to the next page & back to traverse back to the previous page.I have some text fields in the previous page that contain some info.When i click on Next it goes to the next page.when i click on Previous i want to be able to view the input contents in the previous page.I tried using < a href="">
but it blanks all the fields ....
Somebody help
Regards,
ChaitraUse theseus mvc framework. (http://sourceforge.net/projects/theseus-mvc). It will teach you to properly and cleanly right web sites the way they should be, where JSP pages server only as a "view", the action class (servlet hybrid so to speak) handles passing form data to logic, logic returns to action class that then populate the request that is passed on to the JSP page to make use, especially if you use a JavaBean or taglib.
-
Passing values between jsp and php
hi there, is it possible to pass values between jsp and
php? i really need to find out the way if there is
any. thanks in advance
-azali-Yes, there are a few ways to do this.
1) Think about using Cookies.
2) Maybe use a Redirect passing the values in the Query string.
3) Retain the data in a repository in the back end.
4) Using Hidden fields within your pages.
I am sure you can use these Idea's for a base to develop other methods on how to pass values back and forth from JSP -> PHP and vice versa.
-Richard Burton -
Passing Parameter between Methods
I have some problems because i don't really know how to pass parameter between methods in a java class.
How can i do that? below is the code that i did.
I want to pass in the parameter from a method called dbTest where this method will run StringTokenizer to capture the input from a text file then it will run storeData method whereby later it will then store into the database.
How can i pass data between this two methods whereby i want to read from text file then take the value to be passed into the database to be stored?
Thanks alot
package com;
import java.io.*;
import java.util.*;
import com.db4o.ObjectContainer;
import com.db4o.Db4o;
import com.db4o.ObjectSet;
class TokenTest {
private final static String filename = "C:\\TokenTest.yap";
public String fname;
public static void main (String[] args) {
new File(filename).delete();
ObjectContainer db=Db4o.openFile(filename);
try {
String fname;
String lname;
String city;
String state;
dbStore();
storeData();
finally {
db.close();
public String dbTest() {
DataInputStream dis = null;
String dbRecord = null;
try {
File f = new File("c:\\abc.txt");
FileReader fis = new FileReader(f);
BufferedReader bis = new BufferedReader(fis);
// read the first record of the database
while ( (dbRecord = bis.readLine()) != null) {
StringTokenizer st = new StringTokenizer(dbRecord, "|");
String fname = st.nextToken();
String lname = st.nextToken();
String city = st.nextToken();
String state = st.nextToken();
System.out.println("First Name: " + fname);
System.out.println("Last Name: " + lname);
System.out.println("City: " + city);
System.out.println("State: " + state + "\n");
} catch (IOException e) {
// catch io errors from FileInputStream or readLine()
System.out.println("Uh oh, got an IOException error: " + e.getMessage());
} finally {
// if the file opened okay, make sure we close it
if (dis != null) {
try {
dis.close();
} catch (IOException ioe) {
System.out.println("IOException error trying to close the file: " +
ioe.getMessage());
} // end if
} // end finally
return fname;
} // end dbTest
public void storeData ()
new File(filename).delete();
ObjectContainer db = Db4o.openFile(filename);
//Add data to the database
TokenTest tk = new TokenTest();
String fNme = tk.dbTest();
db.set(tk);
// try {
//open database file - database represented by ObjectContainer
// File filename = new File("c:\\abc.yap");
// ObjectContainer object = new ObjectContainer();
// while ((dbRecord = bis.readLine() !=null))
// db.set(fname);
// db.set(lname);
// db.set(city);
// db.set(state);
} // end class
Message was edited by:
erickhIn a nutshell, you don't "pass" parameters. You simply call methods with whatever parameters they take. So, methods can call methods, which can call other methods, using the parameters in question. Hope that makes sense.
Maybe you are looking for
-
Error while upgrading SAP R/3 Enterprise 4.7 to SAP ECC 5.0
Dear SAP, We are on the process of upgrading SAP R/3 Enterprise 4.7 with Ext:110 to SAP ECC 5.0.But during the VERSCHK_INI phase an error is been thrown showing that "The start release configuration : SAP_ABA :620 SAP_APPL :470 SAP_BASIS :620 SAP_HR
-
I've got an old I-phone. How can I determine what model it is? 3 or 4.
I've got an old I-phone. How can I determine what model it is? 3 or 4.
-
Azure Powershell - Calling Set-AzureServiceDiagnosticsExtension results in BadRequest error
I'm trying to set Azure diagnostics on a deployed cloud service using v0.8.11 Azure Powershell cmdlets and the Set-AzureServiceDiagnosticsExtension command: Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigur
-
M'y file pdf multimédia (+audio) is not fonctionnel in Adobe reader android
I prepared a file Adobe acrobat multimedia(+ sound) by my pc. Then the sound does not work on Adobe reader of my Samsung Galaxy Tablet T520 SM
-
I can't contact itunes store. And I recived error messages: Please iTunes support to complete iTunes ID [email protected]