I am facing an issue while passing long value to ksoap request.As ksoap accepts only string and object parameters but i need to pass a long value to the request. Can anybody help me out in this issue.
Request.addProperty("Room No",userid);
Userid is of long type.
Try using Long instance instead of long primitive:
Request.addProperty("Room No", new Long(userid));
Related
I have the following code:
dim key
for each key in Request.Querystring
'do something
key = sanitized_param(key)
next
My question for you classic-asp connoisseur, does classic-asp, or asp in general, pass the variables as references(memory), or by value? Trying to figure out if I sanitize the key variable and pass it back to itself, is it just "alive" for that loop, or does the new value get passed to the original QueryString?
Request.QueryString retrieves the query string parameters by value from the page headers.
You can only make changes to a query string once its been retrieved via Request.QueryString, but you can't make changes directly to Request.QueryString as it's read-only (If you could make changes you would presumably use Response.QueryString, but this isn't a valid response command).
I'm guessing you're trying to sanitize all your query strings in one go? This isn't really possible or indeed necessary. You would typically sanitize a query string as and when you request it:
Response.Write(sanitized_param(Request.QueryString("myQS")))
Or to assign the query string to a variable first then sanitize it:
Dim myQS
myQS = Request.QueryString("myQS")
myQS = sanitized_param(myQS)
' or
myQS = sanitized_param(Request.QueryString("myQS"))
Once the query string has been assigned to a variable and sanitized you're able to reference that variable as often as you like without having to pass it to your sanitize function again.
Also, your example code doesn't make much sense. The key value in your for each loop is referencing just the names of your query strings and not their values. If Response.QueryString was a valid ASP command you would do:
Response.QueryString(key) = sanitized_param(Request.QueryString(key))
But again, this isn't possible.
EDIT: This solution might be what you're looking for:
Create a dictionary object, call it "QueryString" for example. Loop through all your query strings and add a sanitized version to the dictionary object.
Dim QueryString : Set QueryString = Server.CreateObject("Scripting.Dictionary")
For Each Item In Request.QueryString
QueryString.Add Item,sanitized_param(Request.QueryString(Item))
next
Now, to retrieve a sanitized version of a query string just use:
QueryString.Item("query_string_name")
Or for the original unsanitized version you could still use:
Request.QueryString("query_string_name")
Just like Request.QueryString, the dictionary object is forgiving and won't return an error if you ask for a query string that doesn't exist.
You could also create a function for retrieving sanitized query strings, for example:
Function SanitizedQS(ByVal qsName)
SanitizedQS = sanitized_param(Request.QueryString(qsName))
End Function
And rather than using Request.QueryString("query_string_name") just use SanitizedQS("query_string_name").
I've input time field in my Grails application:
<joda:timePicker name="startTimeReservation" value="${new LocalTime()}" precision="minute" />
I want to send its value to action in controller via parameters. This is a code from controller where I catch this value:
oldCafeeInfo.startTimeLimit = params['startTimeReservation']
During parameters are send, I get a such error:
Cannot cast object 'struct' with class 'java.lang.String' to class 'org.joda.time.LocalTime'
How to send parameters correctly?
In request all data is String, so you need to parse string:
oldCafeeInfo.startTimeLimit = LocalTime.parse(params['startTimeReservation'], format)
format is SimpleDateFormat.
Or you can use next answers, for do it automaticaly by binding: Binding a Grails date from params in a controller
I found my own alternative. I noticed what params['startTimeReservation'] comes to controller as a string "struct". Also, in logs, I noticed, what this struct is divide by startTimeReservation_hour and startTimeReservation_minutes. They contain integer-values, which are parse easy! Then these values may be transfered as parameters to the new LocalTime(hour, minute). So we've created new LocalTime instance which can be recorded to the database. Somehow, I doubt this is a good variant, but it works.
I'm encountering the following problem - I have simple GWT overlay types, and I'm trying to convert one to a JSON string on the client; I'm simply doing:
new JSONObject(this).toString();
The conversion works, but it adds an additional, incorrect key to the json string, such as:
{"key1":"value1", "key2":value2, "$H":1}
where "$H":1 doesn't correspond to anything in my overlay type.
Any idea why this is?
Any help is appreciated on this, thanks.
This issue is define in this link
The $H property comes from the
implementation of
JavaScriptObject#hashCode() (in
com.google.gwt.cire.client.impl.Impl#getHashCode(Object)).
In your case, this is due to
AbstractEditableCell maintaining a map
of value keys to their "view data",
and your use (I guess) of the default
ProvidesKey implementation
(SimpleProvidesKey) which directly
returns the item.
So, when rendering, the EditTextCell
calls getViewData, which looks up the
key in the map (and thus needs the
hashcode of the key, hence the call to
hashCode), and the key is your JSO
(hence the new $H property).
I believe that giving a ProvidesKey
implementation (in you case, returning
the name property for instance) to the
Celltable would solve your issue.
I am having doubt in whether to use string or string builder to append html elements like "div" and others in my page in mvc. Is there any other approach for this thing.
Thanks.
I read that Microsoft recommends using StringBuilder when you predict to have more then 6 concatenations.
StringBuilder is the way to go. A String holds a reference to an immutable (fixed) string, and appending to a string is horribly inefficient. If your intention is to repeated perform appends then this is exactly what the StringBuilder was designed for.
You should use StringBuilder if you change string a lot (add, remove, change, replace characters) because it's more efficient. If you do simply operation you should use string.
The problem with string is that it's immutable, so operatrion
string text = myStringVariable + "new string"
causes that the new instance of the text variable will be created. If you do many operation on string class then you will have many instances of string objects.
Whenever you have perform appending texts, you should always use stringbuilder.
Using string would repeatedly create new instances of a string and hence inefficient.
check this post for the depth knowledge about : Why to use StringBuilder over string to get better performance
To be honest and saying something unusual at the end it really does not matter. The differences are so small that you shouldn't care about this and you should invest the time in other things that make difference.
Check this article of Jeff where all this is explained (also in a web environment, when he was creating StackOverflow).
Coding horror article about why does not matter how do you create strings
String bulider Can Be Used When More than One String to be
concatenated.
StringBuilder which is more efficient because it does
contain a mutable string buffer. .NET Strings are immutable
which is the reason why a new string object is created
every time we alter it (insert, append, remove, etc.).
I'm attempting to call a stored procedure, but one of the parameters is "ref long? partyId" and I'm not sure how I'm supposed to pass or not pass something.
What should I be passing in the arguments to either bypass this or appease it?
long? means Nullable<long>. The ref means it is being passed by reference instead of by value. When you pass the value, you need to include ref before the parameter you are passing. Something like this:
long? myLong = 0;
myProcedure(ref myLong);