Can any one help me to get solution for the api changing based on the email id(account details )
ex:
/api/getRooms/test#gmail.com
(last name is changing) for other accounts .
Put all the email ids in the csv with header (Header Name:- Email).
Then, use "CSV Data Set Config" to provide them as inputs to your request. Pass the header as variable to the api like /api/getRooms/${Email}.
Related
In JSP how do I get parameters from the URL?
For example I have a URL www.somesite.com/Transaction_List.jsp?accountID=5
I want to get the 5.
Is there a request.getAttribute( "accountID" ) like there is for sessions or something similar?
About the Implicit Objects of the Unified Expression Language, the Java EE 5 Tutorial writes:
Implicit Objects
The JSP expression language defines a set of implicit objects:
pageContext: The context for the JSP page. Provides access to various objects including:
servletContext: The context for the JSP page’s servlet and any web components contained in the same application. See Accessing the Web Context.
session: The session object for the client. See Maintaining Client State.
request: The request triggering the execution of the JSP page. See Getting Information from Requests.
response: The response returned by the JSP page. See Constructing Responses.
In addition, several implicit objects are available that allow easy access to the following objects:
param: Maps a request parameter name to a single value
paramValues: Maps a request parameter name to an array of values
header: Maps a request header name to a single value
headerValues: Maps a request header name to an array of values
cookie: Maps a cookie name to a single cookie
initParam: Maps a context initialization parameter name to a single value
Finally, there are objects that allow access to the various scoped variables described in Using Scope Objects.
pageScope: Maps page-scoped variable names to their values
requestScope: Maps request-scoped variable names to their values
sessionScope: Maps session-scoped variable names to their values
applicationScope: Maps application-scoped variable names to their values
The interesting parts are in bold :)
So, to answer your question, you should be able to access it like this (using EL):
${param.accountID}
Or, using JSP Scriptlets (not recommended):
<%
String accountId = request.getParameter("accountID");
%>
In a GET request, the request parameters are taken from the query string (the data following the question mark on the URL). For example, the URL http://hostname.com?p1=v1&p2=v2 contains two request parameters - - p1 and p2. In a POST request, the request parameters are taken from both query string and the posted data which is encoded in the body of the request.
This example demonstrates how to include the value of a request parameter in the generated output:
Hello <b><%= request.getParameter("name") %></b>!
If the page was accessed with the URL:
http://hostname.com/mywebapp/mypage.jsp?name=John+Smith
the resulting output would be:
Hello <b>John Smith</b>!
If name is not specified on the query string, the output would be:
Hello <b>null</b>!
This example uses the value of a query parameter in a scriptlet:
<%
if (request.getParameter("name") == null) {
out.println("Please enter your name.");
} else {
out.println("Hello <b>"+request. getParameter("name")+"</b>!");
}
%>
Use EL (JSP Expression Language):
${param.accountID}
If I may add a comment here...
<c:out value="${param.accountID}"></c:out>
doesn't work for me (it prints a 0).
Instead, this works:
<c:out value="${param['accountID']}"></c:out>
request.getParameter("accountID") is what you're looking for. This is part of the Java Servlet API. See http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html for more information.
String accountID = request.getParameter("accountID");
www.somesite.com/Transaction_List.jsp?accountID=5
For this URL there is a method call request.getParameter in java , if you want a number here cast into int, similarly for string value cast into string. so for your requirement , just copy past below line in page,
int accountId =(int)request.getParameter("accountID");
you can now call this value useing accountId in whole page.
here accountId is name of parameter you can also get more than one parameters using this, but this not work. It will only work with GET method if you hit POST request then their will be an error.
Hope this is helpful.
example you wanted to delete the subject record with its subject_id
#RequestMapping(value="subject_setup/delete/{subjectid}",method = RequestMethod.GET)
public ModelAndView delete(#PathVariable int subjectid) {
subjectsDao.delete(subjectid);
return new ModelAndView("redirect:/subject_setup");
}
and the parameter will be used for input on your query
public int delete(int subjectid) {
String sql = "update tbl_subject set isdeleted= '1' where id = "+subjectid+"";
return template.update(sql);
}
page 1 :
Detail
page 2 :
<% String id = request.getParameter("userid");%>
// now you can using id for sql query of hsql detail product
I want change JSON received data from Forecast api to custom units. In API's doc they're wrote i should change query parameters to get this done.
the API call look like this:
https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE
i wonder how i could send option for changing units. this is what they're wrote:
Options
The API request may optionally be modified through the use of query parameters. It will respond to the following:
units=[setting]: Return the API response in units other than the default Imperial units.
Thanks
As the api states that optional parameters can be added as query parameters to the url , your url should look like
https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE?units=VALUE
VALUE is the the type of unit you want to select
Some options are
us
si
ca
uk2
auto
I'm developing a bookstore in mule esb. When I check the quantity from a book order is available with the database, I want to set a property from payload. The payload has several properties from the book (isbn, quantity, prize, avalability), so the last one in this case I want to set to true (is attribute boolean type).
Is there any way to do that with a connector?
not really sure what you're trying to do but...
To change the payload of a message there several ways the easies one being just using a MEL expression.
Say your payload is a map(for you say you toke it from the DB) then you could just do:
<expression-transformer expression="#[payload['avalability']='your value']"
Now you say you wanted that value to be true then the code should look like:
<expression-transformer expression="#[payload['avalability']=true]
MEL will put a boolean true for you there.
Finally to update the DB you should:
<db:update config-ref="Database" bulkMode="true" doc:name="insert contacts to Database">
<db:parameterized-query>
UPDATE books
SET 'avalability' = #[payload['avalability']]
WHERE 'isbn'= #[payload['isbn']]
</db:parameterized-query>
</db:update>
If you want more example about working with DB please check:
https://www.mulesoft.com/library#!/?types=template&filters=Database
You can set the propertyName dynamically using:
#[message.outboundProperties.propertyName]=any value
Consider the following scenario.
I have a Java application which uses Oracle database to store some status codes and messages.
Ex: I have patient record that process in 3 layers (assume 1. Receiving class 2. Translation class 3. Sending class). We store data into database in each layer. When we run query it will show like this.
Name Status Status_Message
XYZ 11 XML message received
XYZ 21 XML message translated to swift format
XYZ 31 Completed message send to destination
ABC 11 XML message received
ABC 21 XML message translated to swift format
ABC 91 Failed message send to destination
On Java class I am executing the below query to get the last status message.
select STATUS_MESSAGE from INTERFACE_MESSAGE_STATUS
where NAME = ? order by STATUS
I publish this status message on a webpage. But my problem is I am not getting the last status message; it's behaving differently. It is printing sometimes "XML message received", sometimes "XML message translated to swift format", etc.
But I want to publish the last status like "Completed message send to destination" or "Failed message send to destination" depending on the last status. How can I do that? Please suggest.
You can use a query like this:
select
i.STATUS_MESSAGE
from
INTERFACE_MESSAGE_STATUS i,
(select
max(status) as last_status
from
INTERFACE_MESSAGE_STATUS
where
name = ?) s
where
i.name = ? and
i.status = s.last_status
In the above example I am assuming the status with the highest status is the last status.
I would recommend you to create a view out of this select query and then use that in your codebase. The reason is that it is much easier to read and makes it possible to easily select on multiple last_statuses without complicating your queries too much.
You have no explicit ordering specified. As the data is stored in a HEAP in Oracle, there is no specific order given. In other words: many factors influence the element you get. Only explicit ORDER BY guarantees desired order. And/or creating a index on some of the rows.
My suggestion: add a date_created field to your DB and sort based on that.
I have a URL www.test.com/myshort/myapp/mypage.jsp, where myshort is a column value in my database.
I will later query for the id of this shortName (in this example it is 'myshort') which I am doing as
select id from mytable where shortName='myshort';
How can I extract the 'myshort' value from the entire URL? I can't do request.getParameter() since this is not a part of the url parameter. So I am trying to use request.getURI().
Can you please tell me how do I parse and get shortName using request.getURI()?
I suggest the use of Spring MVC framework for this type of server programming. It gives you the ability to map request patterns with the actual urls and extract such values from the URL.
I figured out a solution/alternative to my issue. I could go ahead and edit web.xml and specify the url format there.
But this is how I solved my issue. I took off the shortName coming from the url and sticked it as URL parameter. this is much more easier to access than what I was thinking earlier.