Initializing form data

A

Asad

I have a jsp page which checks for an xml file. If it doesn't exist, I
show the users an empty form. However, if the xml file does exist, I
want to auto populate the data in the form using the XML form. The XML
file contains names of the form elements as well as their values.

Right now, all I am trying is that if I have

<%
File Name= new File("sample.xml");
if(!Name.exists())
{
%> sample.xml does not exist <%
}
else
{
%> sample.xml exists! <%
}
Document doc;
Element e;
e = doc.getElementById("t1");
String x;
x = e.getAttribute("name");
out.println (x);
%>

I am trying to create a document element (which should point to the
jsp file that this scriptlet above is embedded in). I am not doing
that anywhere I know; how do I do that is my question.

I have a form btw that has an element as follows:

First Name<input type="text" name="textboxFirstName" size="20"
id="t1">

But when I run this jsp I get this very much expected error:

form1_jsp.java:68: variable doc might not have been initialized
e = doc.getElementById("t1");
^

So how can I get a handle for my jsp file?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top