Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Seeya S Kudtarker
Passing data from jsps to java class
March 11, 2013 12:41 AM

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

I have made a tabbed interface where each tab is a jsp where I accept data from the user. I submit the data only when the user clicks on "submit" which is the last jsp.

Should I use sessions to pass the data from one jsp to another?
for ex. in my first jsp : profile.jsp I have something like:
<input type="text" name="fName" id="fName" size="20" placeholder="Your First Name" required autocomplete="off" />
<input type="text" name="mName" id="mName" size="20" placeholder="Your Middle Name" required autocomplete="off" />
<input type="text" name="lName" id="lName" size="20" placeholder="Your Last Name" required autocomplete="off" /><br><br>
<aui:button type = "submit" value = "Next"></aui:button>
when i click on next it goes to next jsp which is say address.jsp and it has similar input tags like in profile.jsp in addition to the foloowing code:

String fName = request.getParameter( "fName" );
session.setAttribute( "fName",fName);

String mName = request.getParameter( "mName" );
session.setAttribute( "mName",mName);

String lName = request.getParameter( "lName" );
session.setAttribute( "lName",lName);

likewise in 3rd jsp i have used something like <% String mName = request.getParameter( "mName" );
session.setAttribute( "mName",mName);%> to get data from 2nd jsp and so on till the last jsp.

my last jsp has notes.jsp :
<portlet:actionURL name="addEmployeeData" var="addEmployeeDataURL" />
<aui:form name="addEmployeeData" action="<%=addEmployeeDataURL.toString() %>" method="post">

<label for="othernotes">Other Notes:</label><br> <textarea rows="4" cols="50" name = "othernotes" id = "othernotes" placeholder = "Other Notes"></textarea>
<aui:button type="submit" value="Submit" />

addEmployeeData is a function where i process all my data. But problem is when I submit it hsows "null". i.e. the data never went to the function. What am I missing?

here is a snippet of my addEmployeeData function:
public void addEmployeeData(ActionRequest areq, ActionResponse aRes) throws Exception,PortletException,IOException{
String fname = areq.getParameter("fname");
//String mname = areq.getParameter("mname");
String lname = areq.getParameter("lname");

I included print statements in the above function to check if it was showing the input values. It showed null.

What am I missing here?