Servlet unable to get hash fragment from URL [duplicate] - servlets

This question already has answers here:
Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?
(12 answers)
How to get Url Hash (#) from server side
(6 answers)
Closed 1 year ago.
Hi after redirection from OAuth server, I am unable to get the complete URL in my JAVA Servlet.My URL looks like below -
https://host.vp.com/gui/MainPage.gdi#scope=openid%20profile&id_token=eyJ0eXAiOiJKV86sada0ajdasJUUEB343KHFKK
I tried request.getRequestURL() , request.getRequestURL(), request.getPathInfo(), no luck in getting the part of the URL which starts after #, i.e., scope=openid%20profile&id_token=eyJ0eXAiOiJKV86sada0ajdasJUUEB343KHFKK, Can someone help me here?

Your Query string should start with ? instead of # to be able to read in the Selvlet.

Related

Karate; Multiple urls in a single scenario [duplicate]

This question already has an answer here:
Karate API Testing - Reusing variables in different scenarios in the same feature file
(1 answer)
Closed 2 years ago.
This is a followup from a previous question I asked Using response data from one scenario to another
I am looking to take information from a response in one url, then use it in a second url for another assertion.
Something like this:
Scenario: Search for asset
Given url "https://foo.bar.buzz"
When method get
Then status 200
* def responseItem = $.items[0].id // variable initialized from the response
Given url "https://foo.bar.buzz/" + responseItem + "/metadata"
// making request payload
When method put.....
Right now when I run this, it gets hung up on the second Given statement.
Any thoughts on how to resolve this?
As you probably figured out, the "Karate HTML report" will show you the request/response and headers, as long as you put DEBUG log level in your log4j config, and that will answer your question.

uploading photo using TIdMultipartFormDataStream and request payload data [duplicate]

This question already has answers here:
Http Post with indy
(3 answers)
Closed 4 years ago.
trying to upload picture using idhttp + idssl to change profile photo,,
this the request payload data :
------WebKitFormBoundaryhyy5Vlgv8YpwXz7K
Content-Disposition: form-data; name="profile_pic"; filename="profilepic.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryhyy5Vlgv8YpwXz7K--
i know we should use TIdMultipartFormDataStream to include the photo but i dont know how, it supposed to be something like this UploadParams.AddFile('photo', Edit11.Text);
i know we should use TIdMultipartFormDataStream to include the photo
Yes.
but i dont know how
TIdMultipartFormDataStream only has 3 methods for adding data fields:
AddFormField() (which takes data as a string or a TStream)
AddObject() (which is deprecated)
AddFile()
Since you want to upload a file, it makes sense that you should use AddFile() (unless you open a TStream to the file, then you can use AddFormField() instead).
it supposed to be something like this UploadParams.AddFile('photo', Edit11.Text);
Assuming Edit11.Text contains the full path and filename to the photo file that you want to upload, all you need to change is 'photo' to 'profile_pic', since that is the name of the input field in your WebKit example:
UploadParams.AddFile('profile_pic', Edit11.Text);

difference between 'Response.Redirect' and 'Server.Tansfer' [duplicate]

This question already has answers here:
Server.Transfer Vs. Response.Redirect
(16 answers)
Closed 9 years ago.
Everyone,I must launch my code,
The first way:
Response.Write("<script>alert('Succeed,Will be redirect to the target page')</script>");
string path = Server.MapPath(#"~\Forms\MainForm_SQL.aspx");
Response.Redirect(path);
The second way:
Response.Write("<script>alert('Succeed,Will be redirect to the target page')</script>");
Server.Transfer(#"~\Forms\MainForm_SQL.aspx");
Now,back to the issue,The question is :
01)it works nothing when using the 'first way',That is, it either alerts the message nor goes into the 'Page_Load' of the target page.
02),when use the second way,it first goes into the 'Page_Load' of the target,than it goes back to alert the message.
why it that so unreachable to track the architecture ? can some one help me please?
thanks.
IIRC, Server.Transfer is internal -- that is, it hands off processing to the destination without bouncing the client to another page -- whereas Response.Redirect tells the client to go to the new URL.

How to get the request url from HttpServletRequest [duplicate]

This question already has answers here:
How to get the URL fragment identifier from HttpServletRequest
(2 answers)
Closed 6 years ago.
Say i make a get request like this:
GET http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery|Class|analytics|lightbox|label|jquery-dom|jquery-cookie?q=hello#frag HTTP/1.0
Host: cotnet.diggstatic.com:6000
My servlet takes request like this:
HttpServletRequest req;
When i debug my server and execute, i get the following:
req.getRequestURL().toString() = "http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getRequestURI() = "/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getQueryString() = "q=hello"
How does one get the fragment information ?
Also, when i debug the request, i see a uri_ field of type java.net.URI which has the fragment information. This is exactly what i want. How can i get that ?
"The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server." Wikipedia about the Frament Identifiert
For further reference see the RFC 2394 Section 4.1

Using Special Symbols in ASP.NET MVC Routes [duplicate]

This question already has answers here:
ASP.NET MVC: Route with optional parameter, but if supplied, must match \d+
(6 answers)
Closed 9 years ago.
I want to use the url such as "/ControllerName/ActionName/Id"
Id - only digits or null.
But when I use regular expression in MapRoute, "\d{1,4}", I see the exception - error404 page, when I'm trying to see /ControllerName/ActionName/" page.
Also, I don't know, how I can catch exception with special symbol - ".
Please, help.Thanx.
Try using ( *|\d{1,4}).

Resources