Win a copy of Rust Web Development this week in the Other Languages forum!

Sanjeet Khan

+ Follow
since Aug 29, 2012
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sanjeet Khan

Oh sorry, forgot to add that. I'm doing a POST for the form method.
9 years ago
Hey guys,

I have problem. I have a JSONObject in my JSP page that I need to send to a servlet when the "submit" button on a form is pressed, along with other form data. Currently creating the JSONObject and setting the page attribute as such:

String myUrl = "http://localhost:8888/startexam";
URL url = new URL(myUrl);

BufferedReader reader = new BufferedReader (new InputStreamReader(url.openConnection().getInputStream()));

StringBuilder sb = new StringBuilder();
int cp;
while ((cp = != -1) {
sb.append((char) cp);

String jsonText = sb.toString();
JSONObject json = new JSONObject(jsonText);

JSONArray questionArray = json.getJSONArray("exam");
request.setAttribute("JSONARRAY", jsonText);
request.setAttribute("STARTDATETIME", examID);

When I print this out, the JSONObject and the page attribute print out fine, I get the FULL JSONObject value. When the action is called on submit, a weird thing happens. Here's the form submit code (a table is imbedded):

<td colspan="4">
<input type="submit" value="Submit Answers" /></td>
<td><input type="hidden" name="json" value=<%= request.getAttribute("JSONARRAY") %>>
<input type="hidden" name="startdatetime" value=<%= request.getAttribute("STARTDATETIME") %>></td>

When the form is submitted, the JSON value is:


This is a lot shorter than the actual JSONObject value which is:

{"exam":[{"question":{"choice2":"1000","choice1":"100","category":"TECHNOLOGY","choice4":"2000","choice3":"1500","answer":"choice2","question":"How many megabytes are in a one gigabyte?"}},{"question":{"choice2":"10","choice1":"13","category":"MATH","choice4":"6","choice3":"12","answer":"choice3","question":"How many eggs are in a dozen?"}},{"question":{"choice2":"Database Management System","choice1":"Death Before Mad Skills","category":"TECHNOLOGY","choice4":"Delivery Before Modification System","choice3":"Data Batch Manipulation System","answer":"choice2","question":"What does DBMS stand for?"}},{"question":{"choice2":"Came Lights","choice1":"Camel Crush","category":"PERSONAL","choice4":"Marlboro Smooths","choice3":"Marlboro Menthol","answer":"choice1","question":"What type of cigarette does Imran smoke?"}},{"question":{"choice2":"Red","choice1":"Blue","category":"PERSONAL","choice4":"Pink","choice3":"Orange","answer":"choice4","question":"What is Oscar's favorite color?"}},{"question":{"choice2":"6","choice1":"17","category":"MATH","choice4":"4","choice3":"9","answer":"choice4","question":"What is 2 + 2?"}},{"question":{"choice2":"1","choice1":"0","category":"PERSONAL","choice4":"3","choice3":"2","answer":"choice2","question":"How many siblings does Imran have?"}},{"question":{"choice2":"Earth","choice1":"Mars","category":"ASTROLOGY","choice4":"Jupiter","choice3":"Saturn","answer":"choice4","question":"What is the biggest planet in our solar system?"}},{"question":{"choice2":"54","choice1":"47","category":"MATH","choice4":"49","choice3":"63","answer":"choice3","question":"What is 7 x 9?"}},{"question":{"choice2":"Giant Orange","choice1":"God","category":"ASTROLOGY","choice4":"Quasar","choice3":"Star","answer":"choice3","question":"What is our sun?"}},{"question":{"choice2":"Quasar","choice1":"Black Hole","category":"ASTROLOGY","choice4":"Helixical Formation","choice3":"Chocolate","answer":"choice1","question":"What is usually at the center of every galaxy?"}},{"question":{"choice2":"7","choice1":"3","category":"MATH","choice4":"4","choice3":"8","answer":"choice4","question":"How many pints are in a gallon?"}},{"question":{"choice2":"No Structured Query Language","choice1":"Never On SQL","category":"TECHNOLOGY","choice4":"New Orders Serve Quiet Leaders","choice3":"Not Only SQL","answer":"choice3","question":"What does NoSQL stand for?"}},{"question":{"choice2":"10x","choice1":"4x","category":"ASTROLOGY","choice4":"1x","choice3":"8x","answer":"choice1","question":"How man times greater is the sun's circumference than the moons? "}},{"question":{"choice2":"Onion","choice1":"Pepperoni","category":"PERSONAL","choice4":"Ham","choice3":"Bell Peppers","answer":"choice2","question":"What is Imran's favorite topping on pizza?"}},{"question":{"choice2":"9","choice1":"8","category":"ASTROLOGY","choice4":"6","choice3":"4","answer":"choice1","question":"How many planets do we have"}},{"question":{"choice2":"Battlefield","choice1":"Dragon's Dogma","category":"PERSONAL","choice4":"Assassins Creed","choice3":"Gears of War","answer":"choice2","question":"What is Imran's favorite Xbox game?"}},{"question":{"choice2":"Raleigh, NC","choice1":"Richmond, VA","category":"PERSONAL","choice4":"Calcutta, India","choice3":"Goa, India","answer":"choice4","question":"Where was Imran born?"}},{"question":{"choice2":"Cookies Preparation Utility","choice1":"Computer Processing Unit","category":"TECHNOLOGY","choice4":"Computing Preparation Unit","choice3":"Computer Processor Unit","answer":"choice3","question":"What does CPU stand for?"}},{"question":{"choice2":"Great Band","choice1":"Gigabyte","category":"TECHNOLOGY","choice4":"Green Bay","choice3":"Greatbyte","answer":"choice1","question":"What does GB stand for?"}},{"question":{"choice2":"Reliable Available Memory","choice1":"Remaining Available Memory","category":"TECHNOLOGY","choice4":"Random Available Memory","choice3":"Random Access Memory","answer":"choice3","question":"What does RAM stand for?"}},{"question":{"choice2":"blue","choice1":"yellow","category":"ASTROLOGY","choice4":"red","choice3":"orange","answer":"choice1","question":"What color is the sun?"}},{"question":{"choice2":"2","choice1":"1","category":"MATH","choice4":"4","choice3":"3","answer":"choice3","question":"How many sides does a triangle have?"}},{"question":{"choice2":"25","choice1":"30","category":"MATH","choice4":"40","choice3":"20","answer":"choice2","question":"What is 5 x 5?"}}]}

I have been all over the web, forums, text books, resources, etc. and I can not find a simple solution to just send the JSONObject intact within the request body.

Any help would be greatly appreciated!

9 years ago
Ok, that's what I figured, I just wanted to make sure. I asked a few of my colleagues about Tomcat 7 installation problems, mainly around the difficulty creating a jvm because it can't find the .dll file. Since I'm running a 64 bit machine with a 64 bit JDK/JRE, it shouldn't be a problem. I'll try just the Tomcat 7 installation without XAMPP and hopefully it should work.

I'll post back if anything odd happens.

Thanks for now!
9 years ago
Hello everyone,

I'm new to this forum, but I figured it would be a good place to start to find some information on a personal project, information that I haven't been able to find as of yet anywhere else.

I'm beginning development of a web application using JSP, and I have been trying to set up the environment as I understand it needs to be set up, so here's the background. I want to host my pages on a Tomcat 7 server, along with java web services, along with a MySQL database.

My initial thought was to load XAMPP with Tomcat 7 on my machine for testing purposes, especially since it comes with a MySQL database. btw, I'm running on a Windows 7 machine.

I was able to install XAMPP and the Tomcat add on, but when I tried to start the Tomcat service, it was just stuck in the start phase. Upon checking the catalina log, it seems that it is unable to start/find a jvm.dll.

Now, I have a 64 bit JDK/JRE running version 6, and the solutions for this don't work. I'm thinking about ONLY getting the Tomcat 7 server, not the XAMPP, and just a MySQL download.

The question is whether having ONLY Tomcat 7 and MySQL instance be sufficient for me to mimic the environment for my application/services before deployment to a Tomcat host? And second, are there any issues with Tomcat 7 installation on a Windows 7 machine, and what are the REAL fixes?

Imran Khan
9 years ago