Learn how to a build a cloud-first strategyRegister Now


problem in jsp and action

Posted on 2007-07-30
Medium Priority
Last Modified: 2012-05-05
I want to send a  parameter from a jsp page...and i want to get it in the action class.

i want to do this ...because i want to know from which page this action is called .

so, i did

session.setAttribute("pageTracker","fromManagement");  at the top of the jsp page

And in the action class i did

// do something


is this correct ?  but this seems erroneous ....i am not getting the desired result.

I cant use hidden parameter in the jsp form ...because the form is html:form ..a struts  from  .

In fact i am looking for a way so that  my action class can know from which jsp it is coming.
Question by:cofactor
LVL 14

Expert Comment

ID: 19592406
You can try print out the value in the session see if the action able to get the value.

However, is best not to store the value in session, from what I see this is a per request action.
Not sure why you cant use hidden value in <html:form>, there's no problem using <html:hidden ..> unless the value you are storing is P&C.

Author Comment

ID: 19596855
If  i  use  hidden param  ...then do  i need to  add a property for this hidden parameter  into the action from bean ?

LVL 14

Accepted Solution

boonleng earned 100 total points
ID: 19597470
Yes, if you use the struts form tag, it will look for the property name in form bean.
If you don't want to create the property in form bean, then use <input type="hidden"..>. This way you have to get the value from request.getParameter().

Assisted Solution

ayeen earned 100 total points
ID: 19657489
can you try this:

in your jsp:
<html:hidden name="yourFormBean" property="pagetracker" value="Coming from JSP1"/>


in your struts-config:
<form-bean name="yourFormBean" type="com.YourFormBean"></form-bean>

<action path="/whatever" type="com.YourActionForm" name="yourFormBean" scope="session">
      <forward name="go" path = "/WEB-INF/pages/YourJSP.jsp"/>            


in your YourFormBean:

private String pagetracker;

public String getPagetracker()
      return pagetracker;
public void setPagetracker(String pagetracker){
      this.pagetracker = pagetracker;


in your YourActionForm:

private String form_pagetracker = "";

public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception

YourFormBean bean = (YourFormBean) form;
form_pagetracker = request.getParameter("pagetracker");      

// Finish with                                    
return (mapping.findForward("go"));


Expert Comment

ID: 20213307
Forced accept.

EE Admin

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month21 days, 4 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question