Web Services :: GET Or POST - Determine If Passed In Integer Is Prime Or Not
Jan 27, 2015
I have an endpoint that will determine if a passed in integer is prime or not. Should the request to this endpoint be GET or POST? Right now, I'm thinking it should be GET since it doesn't do anything to any resource.
I created the WSDL first in RSA and then created the java bean skelaton from the WSDL. There are a couple of dateTime fields in the WSDL that are created as GregorianCalendar objects.
When I test with SOAPui and the date fields are passed correctly, everything works great. But when there is an invalid date format or anything else in the SOAP request, instead of returning a Conversion exception or some other validation exception, the field is passed as a null to the request object in the SOAP IMPL. Should't this return an exception?
Sample requests inputs: <endTimeStamp>2014-01-28T01:30:14.474Z</endTimeStamp> - Date <endTimeStamp>06-FEB-14 01.51.00.000000000 AM</endTimeStamp> - Null <endTimeStamp>Any other string be it a date or not.</endTimeStamp> - Null
I write a small program. I want post my integer variables in the next class. Here a code(I wanna change answer color):
Main class(pagrindine.java): import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; //Mokinio rinkinukas su skaiciofke kur gali keisti atsakymo spalva, pabandyti sukurti uzrasu knygute.
[code]....
So, I want to post variables r,g,b from class slideris.java in the pagrindiness.java.
So I cant figure out why my output for my for loop isn't working properly. So the output for the square comes out right but the for loop isn't working properly for the H. I have tried to figure it out and it should go to the next line but its not.
import java.util.Scanner; public class Random { public static void main(String [ ] args) {
I am new to java and do not understand how to use filters very well. I need to write a code that determines if an integer is not divisible by some value. A filter also contains an upstream filter so that this filter can be part of a chain of filters.
a. Write a Java program to input 10 integer numbers into an array named fmax and determine the maximum value entered. Your program should contain only one loop, and the maximum should be determined as array element values are being input. (Hint: Set the maximum equal to the first array element, which should be input before the loop used to input the remaining array values.)
b. Repeat 1a, keeping track of both the maximum element in the array and the index number for the maximum. After displaying the numbers, display these two messages:
The maximum value is: _________ This is element number __________ in the list of numbers
Have your program display the correct values in place of the underlines in the messages.
c. Repeat 1b, but have your program locate the minimum value of the data entered.
I did parts a and b but for part see i just want to know if i did it correctly or not
import java.util.Scanner; public class MinimumValueArray { public static void main(String[] args) { //Variable Declaration Scanner keyboard = new Scanner(System.in); int size = 10;
[Code] ,.....
When I run it i get this The minimum value is 0.0
The element that holds the value is 0 right away. is this right for the minimum or am i supposed to enter values and it will display the minimum value like in parts a and b wit the maximum? will the minimum just always be 0 or ?
I have a server with a handful of php services. I communicate with these services by creating connections from java code. The services currently respond with XML, but that can be changed if an alternative way can improve performance.
One of the things I need to do is send varying sized payload (some large) to one of the services. My current plan is to create an xml file in java and perform a POST request with the XML as the payload. I am using an XML because the data is very structured.
From a performance point of view, would it be better to send the XML as a file or just as text? Also, is there a better way to send this data? These services will eventually be used by an android app, where performance and minimizing the size of the data packages will be extremely important.
I wrote stand alone program to post message to IBM MQ , not sure if it posted to queue i see these Another 2,102 character(s) omitted is that mean it didnt post complete message? do i have to increase capacity of text size
I have a code issue and I have a below question for the same.Assuming data[] is of type byte[], is the below statement in java -
while((data[p++] & 0x80) == 0x80);
same as -
while ( (data[p] & 0x80) == 0x80 ) { p++; }
I tried with do { p++; } while ( (data[p] & 0x80) == 0x80 ); That also doesn't seem to be the same thing. I am not putting code around this but essentially if I make this change for not using data[p++] code stops working!
public class MyInteger { private int value; public MyInteger(int number){ value = number; System.out.println("Constructor created with value of " + value);
[code]....
I can't seem to get the value for integer1 and integer2 to pass with the setValue method. I get a runtime error stating the I need to have an int value for these two integers.
//checks wether an int is prime or not public static void main(String[] args) { int n = 17; boolean prime = true; if (!(n==2)) { for (int i = 2; i * i <= n; i++) { if (n % i == 0);
We have a big application which is implemented in basic servlet. WE have Get and Post request in servlet. I want to provide them security if any malicious attack will happen on the form submit method. I want to make it secure. In detail, suppose if any user want to submit form/ any ajax request from my application and if he/she changes the method of submission from POST to GET then how I will recognize this?
I know that HTTPServletRequest object have GetMethod() but how I will detect that it is not changed by Tamper data/Fidler/Watir. One more way, I googled is by using GetQueryString() method but lot of the places I have query paramater in my POST request.
I was wondering what the easiest way would be to keep track of everytime someone makes a new post on reddit (social media site, for those who don't know). I want the program to keep track of the number of posts made with a counter, but that's the easy part. How do I set up a program to actually communicate with and monitor reddit's servers in this manner?
And as it is now, the values are not being passed into the shapeArray array. If I "hard code" two shapes into the array in this class, everything works fine later on, but I do not manage to pass values into the array from the createShape() method. I tried several approaches, nothing works.
I'm having some trouble figuring out how to change the value of a variable that is passed into a class. I've tried just changing the variable, I've tried changing it by using the this.variable command, and I've even tried calling the setter class from within the class to change it, but it's still not working right. The first class is the one with Main in it and I just feed it some dummy data:
public class ExamConverter { public static void main(String[] args) { // TODO Auto-generated method stub Age testAge = new Age();
[Code] .....
This is the other class to calculate the age the way we do it on psych tests - it might not be mathematically accurate, but it's what all the tables and such for raw to scaled score conversion are based on, so the math needs to be the same as opposed to "accurate" because of some months having 30 or 31 days, etc.
public class Age { //==================Properties================== // Variables for the test date and client date of birth private int TestMonth; private int TestDay; private int TestYear; private int ClientMonth; private int ClientDay; private int ClientYear;
[Code] ......
Based on this dummy data, the output is: Test: 5/4/2014 DOB: 5/5/1971 Age Years: 43 Months: 0 Days: 0
However, it should be: Test: 5/4/2014 DOB: 5/5/1971 Age Years: 42 Months: 11 Days: 29
I am trying to list of prime number from n to m but my program give only one number
import java.io.PrintStream; import java.util.Scanner; public class Check05B { public static void main(String[] args) { Scanner input = new Scanner(System.in); PrintStream output = System.out; output.print("Enter a number to test: ");
If I have a method that takes an ArrayList of a class called Piece and it uses the setPosition() method from Piece. It is changing the value of the array that I passed in, but I want the ArrayList to stay the same outside of the method. Is there any way I can change only the values on the inside of the method, but keep the same position values outside the method?Here is an example.
Piece class Java Code: public class Piece { private int xCoor; private int yCoor;
I have an application and I would like it to send a file to a web page using POST method.
I've found the HttpClient from Apache, but I had no luck. All the tutorials and samples I can find on the net are for 3.x. I've tried adopting the samples with the HttpClient 4.1 docs, but I failed.
I have a target url of a page and source file path. I get the basic idea of what needs to happen, I am just finding it hard to implement it.
Now that I have set up my dev environment on a new machine with new eclipse, it does not work.
It displays Ï instead of π.
I've already tried adding URIEncoding="UTF-8" to server.xml which did not work since it only affect get not post. I figured out how to get the parameter with correct encoding on the new system:
XML request message using HTTP POST is received by the Servlet interface. While we are reading and trying to parse the InputStreamObject, we are getting the following error message.
doPost java.io.CharConversionException: Characters larger than 4 bytes are not supported: byte 0x8e implies a length of more than 4 bytes
It looks like we are receiving some invalid Non-ASCII characters in the XML message.
The above error is thrown intermittently. Whenever we have this CharConversionException, the servlet gets corrupted and it impacts few good xml messages that follows after the error.
I need to know the following:
1. How to fix this exception and skip the bad message? 2. Is it possible to log the entire xml message in the catch block, whenever we have this exception?
NOTE: we tried different ways, not able to print the xml message, as the inputstream seems to be closed/null, when it reaches the catch block.
Tried the below code , but the servlet process/thread hungs and throws the below error:
Thread "WebContainer : 3" (00000028) has been active for 667781 milliseconds and may be hung. There is/are 1 thread(s) in total in the server that may be hung.
Below is the code snippet:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml"); request.setCharacterEncoding("ISO-8859-1"); OutputStream out = response.getOutputStream(); InputStream inputStream=null;
[Code] ....
Issue of either fixing/overcoming the actual exception and printing out the entire xml message(bad one) in ours log during the catch block.
I am writing a simple program in Java, where I call a method and pass some variables (namely, min and max) as arguments. This method is recursive, so the same arguments are again passed on in each recursive call.
I need to update these variables in recursive calls so that when the calling method uses them, it uses updated values. As it might sound confusing, here is sample code :
// Function 1. void func1() { //Call func2. func2 (int hd, int min, int max, Map<String, String> map); //Other stuff. } // Function 2.
[code]....
As you can see, min and max are updated after each recursive call returns, based on conditions. However, these changes aren't reflected in original min and max, which were used by func1 while calling func2. As far as I know, this happens due to call by value mechanism being used by Java while passing arguments. If I declare min and max as instance variables in the class, my problem is solved. But, I want to know whether there's any other way to update these variables so that changes in original min and max are reflected. Yes, I can return them as an array of 2 elements each time while returning, but it didn't seem a good solution to me.
public class printprimes2{ public static void main(String[] args){ for( int i = 1 ; i <=199 ; i++ ) //iterate 1 - 199; 2 is prime { for ( int j = 2 ; j < i ; j++ ) //iterate 2 - potential composite EXCLUSIVELY; every number can be divided by one and itself
[Code] ....
It doesn't print only prime numbers but all numbers that range from 0 to 199. What do you think I am doing wrong?