Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read XML thru JSP and...

Status
Not open for further replies.

bhushan007

IS-IT--Management
Apr 9, 2001
1
IN
Hi Folks,
I am new to XML. I want to develope a login page which will accept login name
& password. On submit the values are taken thru JSP and should be checked
against data in existing XML file. And then the normal login functionality.
Another is that I have decided a set of XML structure say
<tag1>
<tag2> some data </tag2>
<tag3> some data </tag3>
</tag1>

I want to generate this structure thru JSP & but with different data.
So please help me to achieve this work.
Thanks in advance.



 
Hi.

An example in JavaScript:

<Script Language=&quot;JavaScript&quot; Runat=&quot;SERVER&quot;>

var uname=Request.Form(&quot;UserName&quot;);
var uPwd=Request.Form(&quot;UserPassword&quot;);
var sourceFile = Server.MapPath(&quot;loginXML.xml&quot;);
var source = Server.CreateObject(&quot;Microsoft.XMLDOM&quot;);
source.async = false;
source.load(sourceFile);

var root=source.documentElement;
newNode=source.createNode(1,&quot;user&quot;,&quot;&quot;);
root.appendChild(newNode);
var idk=source.getElementsByTagName(&quot;user&quot;);
var eor=idk.length;
var lastHozz=root.lastChild;

var newElem = source.createNode(1,&quot;name&quot;,&quot;&quot;);
newElem.text=uname;
lastHozz.appendChild(newElem);

var newElem=source.createNode(1,&quot;password&quot;,&quot;&quot;);
newElem.text=uPwd;
lastHozz.appendChild(newElem);

source.save(sourceFile);

</Script>

The XML looks like the following:

<loginlist>
<user>
<name></name>
<password></password>
</user>
</loginlist>


I don't advice to use this example, 'case there is no encryption and checking methods. It's only the way of using xml in JavaScript.

regards, Kirilla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top