File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Null values, post forms....?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Null values, post forms....?!" Watch "Null values, post forms....?!" New topic
Author

Null values, post forms....?!

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Ok guys im using Jakarta, commons, upload to upload a file on to my webserver.

Now that all works fine, however I can access varibles that are enclosed in
<%
String x = ....
%>

request.getParameter.... doesnt work.

In my servlets, how do i get around this (i'd prefer to avoid beans), could you give me example code etc.,

Thanks in advance
Zein
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is an "isFormField" property to the FileItem object.
Just test for true while looping through them.


[ April 18, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Yes, I have tried that, that gets the form fields, thats fine.

But there are other varibles in the that are in <%... %> that I cant seem to access, they just come up as null. Normally I would access them via request.getParameter("...") and that would work.

Any ideas?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Can you post an example?
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Ok the varible i want access is paper_id



In my servlet I have the following code: [I put all the values from the form into a HashMap, I can access them fine, its just values that are not in the form?]



Any ideas, cues etc..?

Thanks Zein
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You'll need to include the value of that variable in the HTML form.



Regardless of the server side technology you are using, it's important to understand how HTTP and HTTP forms work. Two things that I recommend for people trying to get a handle on these concepts are:

1.) Get in the habit of always viewing the HTML source from your browser.
This is the output from your server side code.

2.) Install either a packet sniffer like tcpflow or install the Live HTTP Headers plugin to Firefox.
Either product will allow you to view what gets sent from the browser to the server when you submit a web page form.
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Cheers ben works like a charm [with some light modification]

The code above makes the fields visible on the form, just need to hide them as you dont want the user to seem them.



Thanks for the advice, really appreciate it.

Zein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Null values, post forms....?!