How to get an empty parameter from an url like "example.com/id//"? - url

I am using symfony 1.0 and below is the URL which displays the news description.
http://news4u.com/search/news/id/344158/css//act/n
In the above URL value for CSS is missing and the URL is supposed to be as below
http://news4u.com/search/news/id/344158/css/n/act/n
When I use $this->getRequestParameter('css') to get the value of css, I get it as 'act' and if the do the same for 'act', I get empty value.
$getRequestParameter('css')=act
$getRequestParameter('act')=<EMPTY>
I am getting values for above parameters for the metioned URL.
I want to get value of 'act' in above URL. How to get that?

Related

Cannot bind query parameter; Unknown name basicRequest when retrieving basic insights for a location

I'm trying to retrieve insights for a location using the Google Business Profile API. I've tried a few approaches, but I always get an error about "Cannot bind query parameter".
According to the docs, I should be posting to this URL: https://mybusiness.googleapis.com/v4/accounts/xxx/locations:reportInsights
and in the body, pass in an array of locationNames, but when I do that, I get the error about "Cannot bind query parameter 'locationNames'".
So I just tried doing a GET on this URL and pass in the names on the name querystring and that worked just fine to get the high-level data.
https://mybusiness.googleapis.com/v4/accounts/xxx/locations:reportInsights?name=accounts/xxx/locations/xxx
So I know I have the right account ID, location ID, etc. But I need to be able to add in the basicRequest parameter so I can indicate which metric that I want to retrieve.
So I've POST to both of those URLS above with a body that looks like this:
{"basicRequest":{"metricRequests":[{"metric":"ALL"}],"timeRange":{"startTime":"2020-10-12T01:01:23.045123456Z","endTime":"2022-01-10T23:59:59.045123456Z"}}}
But again, I get the same errors about "Cannot bind query parameter" to field "basicRequest" (Same as when I tried to pass in the "locationNames" param in the JSON.
So clearly, I'm doing something wrong with how I am sending in the parameters in the body because it doesn't seem to think any of those parameter names are valid. My end goal is to be able to retrieve queries_direct, actions_total, etc.
I'm using Ruby, and there isn't a client library for it, so I'm just crafting the URLs and the JSON body and doing a GET or POST to it.
Greatly appreciate any pointers!

Thymeleaf th:text displaying wrong value on encoded parameter

The URL of the template is:
http://localhost:8080/login?error=Usu%E1rio%20inexistente%20ou%20senha%20inv%E1lida
where, for example, %E1 is á
I'm trying to display the value of the param error on the page using this code:
but a wrong value with special character is being displayed.
Welcome to SO.
I see two ways you can try:
1) Use the utility for an HttpServletRequest:
<p th:utext="${#httpServletRequest.getParameter('error')}">[error message]</p>
This is getting the value of the error parameter from the request.
2) Use the typical usage for getting the value of a param:
<p th:utext="${param.error}">[error message]</p>
In either case, you can use th:if to check for null. You can use utext to get the unescaped text so that unusual characters display.
Also, check that your character encoding is set to UTF-8. In your config, it would look something like:
resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
or
resolver.setCharacterEncoding("UTF-8");
Instead of trying to decode the URL, I first encoded the error message where it was generated using URLEncoder.encode(errorMessage). So, the URL changed to http://localhost:8080/login?error=Usuário+inexistente+ou+senha+inválida. Then, I didn't need to decode. I only used th:text="${param.msgError}

Kibana 4 : Url not formatted properly

I have a field in my index like
path: /abc/nvb/jklk.txt
I autoindex it as string and it is displayed as above. Now, i want to convert it to a url. So in the index settings in Kibana, i apply set this field as a Url and apply
Url Template
hostname:portNumber#{{value}}
Label template
{{value}}
now this field appears as a link in my discover view. But when i click on it, it navigates to
hostName:portNumber#%2Fabc%2Fnvb%2Fjklk.txt
why did all of my /s get replaced by %2F ? Note that, i was expecting the link to navigate to
hostName:portNumber#/abc/nvb/jklk.txt
which is indeed a valid url
I have tried putting the value as
path: //abc//nvb//jklk.txt
and even
path: \/abc\/nvb\/jklk.txt
but the result is the same. The slashes always get encoded. Is there a way to solve this? Will I have to modify my mapping?
it should be
Url Template
hostname:portNumber#{{rawValue}}

Can't get params from url on Grails application

I'm trying to get parameters from the url using param in a controller. My url is: .../index?format=json
I've tried to get the params from the following two methods:
def format = params.format
def parameters = getParams()
The below is what I get in the debug results:
My question is why the format value isn't coming through in the code?
The format parameter gets populated by the type of content you are asking for (JSON, XML, etc). So, a request parameter called format will get overridden.
See here for more details: Grails 2.3.x: get the value of URL parameters

Get "Default" Route Url in Controller

Can anyone tell me what is the syntax for retreiving the actual URL for the "Default" Route?
I'd like to do something like:
string url = RouteTable.Routes["Default"].ToString();
//(even though that code is completely wrong)
so that I could have the url value of the route available to work with.
So far, I've been trying the .GetVirtualPath() method, but that only returns the route data for the current controller.
thanks
Dave
A route can match any number of urls. So a route doesn't have a url. To get a url from a route you will have to supply it with the route data that you want the url for. To do that you simply use the RouteUrl() method on the Url property, Url.RouteUrl().
Update
If you want the url that will be generated if you supply the route with its default values you can do something like this:
var url = Url.RouteUrl("Default", ((Route)RouteTable.Routes["Default"]).Defaults);

Resources