Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null values, post forms....?!

 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic