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

x
?
Solved

Append key/value pair in URL java

Posted on 2011-09-06
14
Medium Priority
?
414 Views
Last Modified: 2012-05-12
We have a scenario in our mobile app where we want to add a parameter to the header or url so that the firewall can validate the request based on the parameter sent. Authentication needs to be done before it reaches the server. Is there anyway to append any information to url or request headers for the subsequent requests from the server.

 I like  to append name/value pairs to the URL's from within a servlet or action class so that based on the key value pair we can have a rule in firewall to validate the request.

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
  • 6
  • 5
  • 3
14 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36491168
If I understand you correctly then if you use attribute method=get
in the <form... > element then it will pass your parameters in
the URL itself
Yu can then use say hidden element(s)  to pass any parameters you want in the URL
string to the next page
0
 

Author Comment

by:greenearth
ID: 36491179
all the jsp's use POST method.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36491187
You can use servlet instead of JSP
0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 47

Expert Comment

by:for_yan
ID: 36491203
0
 
LVL 47

Accepted Solution

by:
for_yan earned 1000 total points
ID: 36491241
It is not recommended to use GET method
mostly because folks don't like to see
parameters in the URL,
but if you specifically want it, you can still use GET method

http://www.exampledepot.com/egs/javax.servlet.jsp/getparam.html

http://www.tutorialspoint.com/jsp/jsp_form_processing.htm
0
 

Author Comment

by:greenearth
ID: 36491251
this is an existing application so I would not be able to change the architecture.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36491367
So what can you do?
Maybe you can change the action of the form direct it to intermediate servlet
which would modify the URL and then call your ultimate page
and in that itntermediate servlet uyou'll change as you want.
0
 

Author Comment

by:greenearth
ID: 36491368
moreover GET would have size limit, the app might have many fields in the form.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36491479
Last I heard, Authentication is always done by the server.
0
 

Assisted Solution

by:greenearth
greenearth earned 0 total points
ID: 36492609
after the initial authentication on the server we want to add information or token  either in the request header or URL for the firewall to authenticate all other subsequent requests. Is this possible to do?

One of the approaches I was thinking was cookies, with which we can get back information every other subsequent requests. We are looking for any other alternate approaches as cookies maybe disabled on the browser.

Any suggestion is aprreciated.
0
 

Author Closing Comment

by:greenearth
ID: 36553477
This is not a complete solution, as we are not looking for GET requests.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36524728
I guess you don't understand then that "I like  to append name/value pairs to the URL's" is by definition a GET request.  You can not put or see POST requests in the URL.
0
 

Author Comment

by:greenearth
ID: 36524901
Dave .. you can append parameters to POST requests explicitly like this

<form id="form1" name="form1" method="post" action="print?<%= session.getAttribute("auth") %>

let me know if this is wrong
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36525013
No, that is not 'wrong' but the server receives the part after the URL and '?' as a query string and puts that in the GET array, not the POST array.  I have done exactly what you are talking about a number of times and you will Not find that info the POST array on the server.  It will be in the GET array though sometimes (in PHP), you can retrieve it thru the REQUEST array which in PHP combines both POST and GET.

So when you submit a form as a POST with a query string, you are submitting both POST and GET information.  Yes, you can do that (I have done that) but you have to know which is which so you know where to look for the different items in the program page that receives the info.

Note that these things are independent of the language, they are part of the HTTP protocols that browsers and servers use.  http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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 …
Suggested Courses

664 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