Solved

How to add a variable to URL in struts

Posted on 2011-09-12
9
350 Views
Last Modified: 2012-05-12
Is it possible to add a parameter to the url at framework level in struts 1.2. I need to get a back a parameter always in the URL. any alternate approaches are also welcome.
0
Comment
Question by:greenearth
  • 5
  • 4
9 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 36526019
I don't use Struts. If you can't find a Struts way, then maybe you could use a Filter.
Please give us more details.
Where is the URL ?
Do you want to add a parameter to each request to your web app ?
0
 

Author Comment

by:greenearth
ID: 36529562
yes, I want to add an authkey to the url always so that my firewall will be able to validate the request coming through. So all the requests needs to have this parameter in the url.
0
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 36530421
I am still trying to understand your requirements. Is this question the same as your last question ?
http://www.experts-ex  change.com/Software/Server_Software/Web_Servers/Q_27293827.html  
There you posted
><form id="form1" name="form1" method="post" action="print?<%= session.getAttribute("auth") %>  
Which by the way should be
<form id="form1" name="form1" method="post" action="print?authkey=<%= session.getAttribute("auth") %>
>So all the requests needs to have this parameter in the url.
You mean any request from anybody ? If so, then what would be the point of authentication ?
I guess you are talking about requests from forms on your web pages.
If the user has joined a session, then the "auth" attribute should be there for subsequent requests from the user. So are you talking about incidents when the user has no session ? If cookies are a problem, then you could use url rewriting to encode each url in your web app.  
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:greenearth
ID: 36531199
with url re-writing i have to encode each url and with growing size of the application it would not be a great solution. Is it possible to do this at any framework level, where we can always ask the next request to have this parameter in the url or request header.
0
 
LVL 27

Assisted Solution

by:rrz
rrz earned 500 total points
ID: 36531982
>yes, I want to add an authkey to the url always so that my firewall will be able to validate the request coming through.  
I presume the request must make it through the firewall before it gets to your web server. This would require that the authkey be sent to the client in the last response from the server.  
>with url re-writing i have to encode each url and with growing size of the application it would not be a great solution.  
I believe its standard practice. The easiest way is to use JSTL tag;
<c:url>
0
 
LVL 27

Expert Comment

by:rrz
ID: 36531997
In fact, there must be a Struts tag to do what <c:url> does.
0
 

Author Comment

by:greenearth
ID: 36532738
>yes, I want to add an authkey to the url always so that my firewall will be able to validate the request coming through.  
>>>I presume the request must make it through the firewall before it gets to your web server. This would require that the authkey be sent to the client in the last response from the server.  

Yes , this what I am looking for.

>with url re-writing i have to encode each url and with growing size of the application it would not be a great solution.  
>>>I believe its standard practice. The easiest way is to use JSTL tag;
<c:url>

I am not aware if this is the best approach for scenario like this...

0
 
LVL 27

Expert Comment

by:rrz
ID: 36532839
>I am not aware if this is the best approach for scenario like this...  
You mean when you don't use session cookies ?
0
 

Author Closing Comment

by:greenearth
ID: 36720063
we have finally going with cookies as the firewall will be able to intercept the contents of the cookie
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

860 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