I'm updating a site and am struggling to find a way to get an id from the URL. For example I have this:
http://some.html/search.cfm?id=9900000000301
How do I get the id value "9900000000301" from the URL in Coldfusion8?
I have tried url.id plus all sorts of *cgi.query_string* variations, but the number is still out of reach :-(
Thanks for help!
EDIT:
If I dump the URL struct, I'm getting this:
catch - struct
TYPE: default
VALUE: search
Which is not saying much to me.
The url.id should work just fine.
Url.Id will work - with one exception.
If you have created a variable called Url, it is possible (in Adobe CF) to "hide" the Url scope, and thus not be able to access it.
For example, if you have a function with an argument called url, referring to url inside that function will refer to Arguments.Url, not the Url scope. If this is the case, you need to rename the argument to be able to access the proper Url scope.
(Alternatively, switch to a better CFML engine where scope names always takes precedence over unscoped variables, and thus scopes cannot be hidden.)
Depending on how you are looking to use the data, here are two examples. The first checks to see if it was defined and the second sets a variable to the value.
<cfif isDefined("URL.id")>
<cset myVariable = URL.id>
</cfif>
Hope this helps!
Related
We can use
'PATCH /companies/:id' : 'CompanyController.find'
to update data.
One suggested me that I can use the alternative way:
'PATCH /companies/find?key=Value'
But I do not know what it works. Please explain me why we prefer ? mark than : mark in search path.
You can use either or. The biggest reason most people chose one or the other is just how they want to present the URL to the user.
Using a path variable (:) can symbolize you're accessing a defined resource, like a user ID, where as an argument (?) can symbolize you're are dynamically changing/searching something within a defined resource, like a token or search term.
From what I can tell that's the general practice I see:
example.com/user/:username
versus
example.com/user/?search="foo"
http://en.wikipedia.org/wiki/URL
If we are firing GET request, ? symbol is used to let the server know the url parameter variables starts from there. And this is commonly used. I didn't used : symbol instead of ?
You are probably messing the things up:
According to your example, :id indicates a variable that must me replaced by an actual value in some frameworks such as Express. See the documentation for details.
And ? indicates the beginning of the query string component according to the RFC 3986.
It's a rule to design rest api
you can find 'how to design a rest api'
Assuming below code is Sails.js
'PATCH /companies/:id' : 'CompanyController.find'
It will makes REST API that be mapped onto 'CompanyController.find' by using PathParam. Like this
www.example.com/companies/100
Second one will makes REST API by using QueryParam.
It also be mapped onto 'CompanyController.find'
/companies/find?key=Value
But the API format is different. Like this
www.example.com/companies/find?key=100
PathParam or QueryParam is fine to make REST API.
If the Key is primary for company entity,
I think PathParam is more proper than QueryParam.
i want to pass a parameter in url blank but localhost server tell that it is bad url. are i can make them work in MVC 3
the url is
http://localhost:6251/time/saturdau/first/second//nextparameter
you can see that third parameter is blank here. are this request can work whenever 4th parameter pass without passing 3rd paramter.
what i do to make this work.
rather put a work around on this say you make a convention if the parameter passed is null you may try passing something like my_conventional_null_indicator
so instead of making it look like this
http://localhost:6251/time/saturdau/value1/34//70
do this
http://localhost:6251/time/saturdau/value1/34/my_conventional_null_indicator/70
but the best way would still be the conventional way
http://localhost:6251/time/saturdau?param1=value1¶m2=34¶m3=¶m4=70
or the much better way is to maximize the capability of the RouteValueDictionary.
This is not allowed. You can have optional parameters, but they must be the last segment in the URL. You can't have an optional parameter in the middle.
I have a gwt url like this
http://127.0.0.1:8888/BiddingSystem.html?gwt.codesvr=127.0.0.1:9997#ForumMessage=918
when I am doing this
Window.Location.getParameter("ForumMessage")
I am getting null??
By the way, I not getting the point why this ?gwt.codesvr=127.0.0.1:9997 in the url!!
To get the value of the URL fragment (the part after the #) call Window.Location.getHash(). This will return all of "ForumMessage=918".
getParameter() returns query parameters, not the URL fragment.
See here for more information about the parts of a URL.
The ?gwt.codesvr= part is needed to run in Development Mode.
Look at this topic GWT URL Parameters
Here is answer
url should be http://localhost:8080/?testing=abc#pg5 instead of http://localhost:8080/#pg5?testing=abc
and delete that part (?gwt.codesvr=127.0.0.1:9997 ) and run it in web mode. I think it will solve your problem
I'm unsure what the proper way is to access parts of the requested URL.
In this case, I want to get the requested path without the query variables. This is the only way I found to do it:
String path = getRequest().getResourceRef().getHostIdentifier() +
getRequest().getResourceRef().getPath();
The result would be the bold part of this url: https://stackoverflow.com/questions/ask?query=value
I also found about 6 different ways to get the server name (http://stackoverflow.com) but I'm worried that some of them would fail in certain cases that I am unaware of (why would there be 6 different ways to do one thing):
getRequest().getHostRef().getHostIdentifier();
getRequest().getHostRef().getIdentifier();
getRequest().getRootRef().getHostIdentifier();
getRequest().getRootRef().getIdentifier();
getRequest().getResourceRef().getHostIdentifier();
And this seems to get the complete URL with query parameters:
getRequest().getResourceRef().getIdentifier();
Any further explanation would be much appreciated.
If you're in a UniformResource (or subclass) I think you might be looking for the method getReference(), which returns the URI reference. There are a number of other convenience methods in that class you might be interested in so you don't have to go through the request. See UniformResource (Restlet 2.0).
I'm trying to pass a userId (string) in the URL which will be passed to the database and used by a query in SSRS.
base URL:
http://blah/Reports/Pages/Report.aspx?ItemPath=MyReport
I tried this, but it doesn't work:
http://blah/Reports/Pages/Report.aspx?ItemPath=MyReport&UserId=fred
Any ideas?
First, be sure to replace Reports/Pages/Report.aspx?ItemPath= with ReportServer?. In other words, instead of this:
http://server/Reports/Pages/Report.aspx?ItemPath=/ReportFolder/ReportSubfolder/ReportName
Use this syntax:
http://server/ReportServer?/ReportFolder/ReportSubfolder/ReportName
Parameters can be referenced or displayed in a report using #ParameterName, whether they're set in the report or in the URL. You can attach parameters to the URL with &ParameterName=Value.
To hide the toolbar where parameters are displayed, add &rc:Toolbar=false to the URL (reference).
Putting that together, you can run a URL with embedded values, or call this as an action from one report and read by another report:
http://server.domain.com/ReportServer?/ReportFolder1/ReportSubfolder1/ReportName&UserID=ABC123&rc:Toolbar=false
In the report's dataset properties query: SELECT stuff FROM view WHERE User = #UserID
In the report, set the expression value to [UserID] (or =Fields!UserID.Value)
Keep in mind that if a report has multiple parameters, you might need to include all parameters in the URL, even if blank, depending on how your dataset query is written. That means repeating the parameter name for multiple values of the same parameter, too.
To pass a parameter using Action = Go to URL, set expression to:
="http://server.domain.com/ReportServer?/ReportFolder1/ReportSubfolder1/ReportName&UserID="
&Fields!UserID.Value
&"&rc:Toolbar=false"
&"&rs:ClearSession=True"
Be sure to have a space after an expression if followed by & (a line break is isn't enough). No space is required before an expression. This method can pass a parameter but does not hide it as it is visible in the URL.
If you don't include &rs:ClearSession=True then the report won't refresh until browser session cache is cleared.
To pass a parameter using Action = Go to report:
Specify the report
Add parameter(s) to run the report
Add parameter(s) you wish to pass (the parameters need to be defined in the destination report, so to my knowledge you can't use URL-specific commands such as rc:toolbar using this method); however, I suppose it would be possible to read or set the Prompt User checkbox, as seen in reporting sever parameters, through custom code in the report)
For reference, see this page on URL encoding, e.g. / = %2f
As well as what Shiraz said, try something like this:
http://<server>/ReportServer/Pages/ReportViewer.aspx?%2f<path>%2f<ReportName>&rs:Command=Render&UserID='fred'
Note the path would only work if you are in a single folder. When I have to do this I simply browse to the report using the reportserver path ("reports" is the report manager) and copy the url then add &<ParameterName>=<value> to the end.
Try changing "Reports" to "ReportServer" in your url
According to Microsoft, the format basically is:
http://<server>/reportserver?/<path>/<report>&rs:Command=Render&<parameter>=<value>
Try passing multiple values via url:
/ReportServer?%2fService+Specific+Reports%2fFilings%2fDrillDown%2f&StartDate=01/01/2010&EndDate=01/05/2010&statuses=1&statuses=2&rs%3AFormat=PDF
This should work.
I solved a similar problem by passing the value of the available parameter in the URL instead of the label of the parameter.
For instance, I have a report with a parameter named viewName and the predefined Available Values for the parameter are: (labels/values) orders/sub_orders, orderDetail/sub_orderDetail, product/sub_product.
To call this report with a URL to render automatically for parameter=product, you must specify the value not the label.
This would be wrong:
http://server/reportserver?/Data+Dictionary/DetailedInfo&viewName=product&rs:Command=Render
This is correct:
http://server/reportserver?/Data+Dictionary/DetailedInfo&viewName=sub_product&rs:Command=Render
Use the URL, mentioned below to open the report in a new window with dynamic parameters.
="javascript:void(window.open('http://Servername/ReportServer?/Foldername/Reportname&rs:Commnd=Render¶meter1=" & Fields!A.Value & "¶meter2=" & Fields!B.Value & "'))"
Try changing "Reports" to "ReportServer" in your url.
For that just access this http://host/ReportServer/ and from there you can go to the report pages. There append your parmaters like this
&<parameter>=<value>
For more detailed information:
http://dobrzanski.net/2008/08/11/reporting-services-problem-with-passing-parameters-directly-in-the-url/
https://www.mssqltips.com/sqlservertip/1336/pass-parameters-and-options-with-a-url-in-sql-reporting-services/
http://desktop-qr277sp/Reports01/report/Reports/reportName?Log%In%Name=serverUsername¶mName=value
Pass parameter to the report with server authentication