Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to add a variable to URL in struts

Posted on 2011-09-12
9
Medium Priority
?
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 28

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 28

Accepted Solution

by:
rrz earned 1500 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 

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 28

Assisted Solution

by:rrz
rrz earned 1500 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 28

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 28

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

721 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