1

I'm "translating" a PHP class in Java.

I've a function that takes a key and checks if it's in the $_POST array.

How could I do a similar thing from a class Java method?

3
  • in java no any method to check it is arrat or not.using the size you know it is array. Commented Mar 20, 2012 at 10:25
  • duplicate of stackoverflow.com/questions/5222/… Commented Mar 20, 2012 at 10:26
  • @scibuff: Thank you. I did the research, but I've not found it Commented Mar 20, 2012 at 10:36

2 Answers 2

1

Java doesn't support associative arrays. If you're using a HashMap:

HashMap hMap = new HashMap();
//(...)
ht.put("key","One");
ht.containsKey("key"); // returns true

If you're using a hashtable:

Hashtable ht = new Hashtable();
//(...)
ht.containsKey("key");

Unless you mean how to access POST parameters, then check this question and this documentation

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you. I mean how to access POST parameters. But if I've not a servlet? I'm trying to translate in java the botsko.net/blog/2009/04/07/jquery-form-builder-plugin example from php.
If it's not a servlet then what is it? How does it act as a server?
I'm trying to use a jquery formbuilder plugin following the php example on botsko.net/blog/2009/04/07/jquery-form-builder-plugin. My idea was to "translate" the classes in java and then create the corresponding objects and call the methods from a jsp in <% %> (without using a servlet). But now I'm realizing that it's impossible a complete "translation" from php to java.
Hi @Cricket, I'm stuck with the same plugin. I'm trying to translate it from PHP to Java, but since I don't know PHP much, I'm stuck. Did you complete this project? What did you use eventually? Can you kindly guide me?
@LittleLebowski: The project on github uses object oriented php. You could use the same two classes by making changes according to your project. As java doesn't support associative arrays like PHP, I've used Hashtable<String, Object>, but it complicates some things that in php are simpler. However, you should try to understand the php code and above all the json structure.
0

Look up request.getParameter()

http://www.roseindia.net/jsp/GetParameterMethodOfRequest.shtml

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.