GeeCON Prague 2014*
The moose likes Struts and the fly likes how to get the url append values in strut Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to get the url append values in strut" Watch "how to get the url append values in strut" New topic
Author

how to get the url append values in strut

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Hi,

When i click on the link i am getting like this URL

http://localhost:8080/cyberq/jobapply!add.action?cyberQ1

i want to get cyberQ1 values from the above url.

Please help me how to do this.


Thanks





Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688


hi pankaj,

you can get value of cyberQ1 with two ways.

1) make declaration of cyberQ1 in your action and make getter and setter for cyberQ1 variable. Then you can directly use this cyberQ1.

2 ) Second is you can access it using request object. Like request.getParameter("cyberQ1");




Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
But cyberQ1 is not my fix url values it can changes when clicks on hyperlink

like



by click the above url the values changes ever time.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688


hi,

But if your parameter name cyberQ1 change every time then you have to change at make it same.

Because if you want to access some parameter value at least you have to name of this parameter.

other wise how would you access it. ???

so you have at least name of that.
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Hi,

Let me explain my problem.

I am have jsp page which showing list of jobs.

for every jobs there is a link ApplyOnline.


When the user click on the link then this url values changer ever time.


joblist jsp page

















Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688


Hi,

I think here your parameter cyberQ1 value change but your parameter name always same cyberQ1

so , you can follow my first Answer.

Value does not affect your code.

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Hi Nishan,

In first post you gave two answer which one is good.


Thanks
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688



Hi,


I think both one is good.

But if you don't want to access request object then first one is good.

if you want to access request object you have to implements your action to ServletRequestAware and implement the methid of this interface and then you can aaccess you request object.

So i think first one is good for you.

At last choice is yours.

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Thanks Nishan i got my solutions.
and i used first approach.
 
GeeCON Prague 2014
 
subject: how to get the url append values in strut