I am facing one problem.
I have one application say A which is being hitted from other application say B.
When someone hits the application A from B there is one URL (my application i.e A url ) get created.
So I copies all the requestParameter and uses it for processing.
But now in one of my parameter it has value whihc is having # in value e.b ABC#xyz
The problem is when I tries to get all parameters the values after # did not come through request.
I tried below all things but i did not get the complete url and thus i am stuck
Can any one came across such issue? Any common methodology to follow in this case?
Have you tried
Returns: a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.
It seems to be designed to be used in conjunction with
StringBuffer getRequestURL() [...]The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
If this request has been forwarded using RequestDispatcher.forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse), the server path in the reconstructed URL must reflect the path used to obtain the RequestDispatcher, and not the server path specified by the client.
Because this method returns a StringBuffer, not a string, you can modify the URL easily, for example, to append query parameters.
This method is useful for creating redirect messages and for reporting errors.
As Istvan said, if A (the one being 'hit' with the HTTP request) is a Servlet, then you should use the methods he described to get the correct parts of the string, or better, use the request.getParameter(paramName) method...
But that is just part of the problem. The problem seems to be that you are not making a valid HTTP request URL from application B. You need to make sure the URL follows all the rules for URLs. One rule that you broke was the use of special characters. The # sign means something specific in a URL, so when you try to use it for anything else you break the contract and the characters can be handled differently than you expect (they may never actually reach the Servlet).
So first things first:
- Read up on the HTTP protocol and make sure the URL you build follows the rules, and understand what the different characters mean.
Then, you are going to understand that the #, and other special characters may end up in the data you want to send over the URL, so how do you fix that? The answer is to 'encode' the strings:
The URLEncoder class is designed just for this purpose. It identifies all the 'special characters' in the string you provide and replaces them with escape sequences. And if you do it right then you may not even have to worry about decoding it on the receiving side - it may be done for you automatically. In the situation when it is not done for you, you can use the URLDecoder class to do it yourself.
posted 10 years ago
Thanks Steve !!
I tried those method too.
Only thing I want to check that if I am not aware of any process/method which will help me,
As my application is being accessed from other application I was trying to figure out if I can do anythin at my side.
But it seems the application A will need to change the logic so that the URL will not have specail charcters in normal format.
Once again thanks for your reply.
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.