how to get linkname from jsp to struts action class

Hi ,

I want to get name of link from jsp page to my struts action class.

following is in my jsp page

<a href="getjobdetails.do"><bean:write name="jobActionForm" property="jobname" /></a>

when I click on perticular job name the jobname should be pass to my struts action

I tried to get this name like follow

String jname=request.getParameter("jobname");

but it taking null value..

can anybody help me plz?

Thanks in advance.

[606 byte] By [mona_1deca] at [2007-11-27 2:27:50]
# 1

Use a javascript function for this.

<a href="getjobdetails.do" onclick = "abcd('<bean:write name="jobActionForm"property="jobname" />')">

<bean:write name="jobActionForm" property="jobname" />

</a>

in the javascript function assign the value to a hidden variable or the same variable jobname and then access this variable in the Action class.

JHyenaa at 2007-7-12 2:39:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
No it still giving null value.Please suggest some another way.
mona_1deca at 2007-7-12 2:39:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Method 1:

You are getting null because when your form submit type is POST, it will not submit your html labels.

Try to sumbit the label value by placing a hidden field with the same label property.

<html:hidden property="jobname" />

<a href="getjobdetails.do">

<bean:write name="jobActionForm" property="jobname" />

</a>

Method 2:

Append the job name to the action url in your javascript function:

your JSP

<u>

<a onMouseOver= "this.style.cursor='hand'" onclick='javascript:setActionString(<bean:write name="jobActionForm" property="jobname" />)'>

<bean:write name="jobActionForm" property="jobname" />

</a>

</u>

your JavaScript

<script type="text/javascript">

function setActionString(actionStr){

document.jobActionForm.action = 'getjobdetails.do?jobName='+ actionStr;

document.jobActionForm.submit();

}

</script>

your Action

String jname=request.getParameter("jobName");

SirG

SirGenerala at 2007-7-12 2:39:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...