March 6, 2000

Remote File Size

Question: How can I discover the size of a remote file stored on an HTTP server? Answer: The HTTP protocol supports the transfer of extra information about thecontent referenced by a URL. This information is stored in the HTTPheader fields. The Content-Length header provides the size of theobject referenced by

Determining Heap Size

Question: How do I find the size of the heap memory that is available for Java program? Answer: The maximum size of the Java heap is fixed by the JVM runtime atstartup, but usually starts from a smaller initial value and graduallygrows to the maximum value as more memory is

Form Input and JSP

Question: I want to collect form data in a JSP page where the form issubmitted by one of many possible links (possibly passing values usingURL rewriting). In one case, I have one text input box, followed bytwo links. The text input box’s data ends up in the HttpServletRequestobject. How do

Destroying Objects

Question: In VB, you can release the object’s memory with the following: set object = nothing How do you accomplish the same thing in Java? Answer: The analogous way of doing this is to set an object to null: object = null; However, this does not immediately free the memory

String Search Mechanism

Question: How do I do a string comparison where I want to determine if onestring is contained within another? For example: Str1 = “Degree in IT”;Str2 = “Diploma or Degree in IT”; I want to see if Str1 is contined in Str2. Answer: The String class supports this type of

Pass Both the Value and Text of a SELECT Control

Question: How do I pass both the option value and option label parameter through ASP? select one Answer: Create a hidden input (text) box within the form: Then, write code for the ONCHANGE event of the SELECT control to populate the hidden text box: When the user chooses an option

ServerSocket Port Binding Error

Question: My Java server compiles perfectly, but when I try to run it on mymachine I get an error when it tries to open up the ServerSocket onport 2525. I have tried it on another machine and it works fine. Italso worked on my own machine the first few times

JVM Process ID

Question: On a POSIX-compliant system, is there a way to get the process ID ofthe JVM running the current code? Answer: There is no standard means of obtaining the process ID ofthe JVM. The most efficient way of implementing this is to write aJNI method that produces this information. However,

Date Arithmetic in Java

Question: I have a ResultSet created using JDBC and it contains some datefields. Now I want to subtract one date from the other. Howdo I do this? Answer: Date arithmetic in Java is performed by instances of the Calendarclass. The Date class, and subclasses thereof, are place holders for dateand

No more posts to show