subrahm puvvada

Greenhorn
+ Follow
since Aug 23, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by subrahm puvvada

i have ajsp file which which allows user to enter some data .
when u click submit button the values you are entered should be updated to the datbase.
when u call the same jsp file the updated values should be displayed
18 years ago
JSP
i have one situation
in jsp thereare values in the combo
and whenu select the value in the combo that corresponding values are displayed in table

sno field bolean
1 aa required here one checkbox will be there
2 aaq required here one checkbox will be there
3 aa c required here one checkbox will be there

when u select the checkbox that values areupdated in database.

up to this no problem.

when u call the same jsp file the updated values are displayed innplace of required.
for eg i fu check the yes should be displayed otherwise no should be displayed
18 years ago
JSP
i have one situation.
in jsp when u check items and click submit button the checked values are sumitted to the database.that i have done it
if u don't check any one and click submit button then server500 error is comming.
how to handle this situation
18 years ago
JSP
how to get the servlet version in jsp
18 years ago
JSP
String[] checkedValues= request.getParameterValues("checkit");
i have placed like this also
but the exception is comming
18 years ago
JSP
sorry i have given there stringarray only not string.
i have forgotten to modify and posted
18 years ago
JSP
<%@ page import = "javax.xml.parsers.DocumentBuilderFactory"%>
<%@ page import = "org.w3c.dom.*"%>
<%@ page import = "javax.xml.parsers.DocumentBuilder"%>
<%@ page import = "javax.xml.parsers.*"%>
<%@ page import = "java.io.*,java.util.Vector,javax.xml.transform.Transformer,javax.xml.transform.TransformerFactory,javax.xml.transform.dom.DOMSource,javax.xml.transform.stream.StreamResult"%>
<% String[] checkedValues=(String) request.getParameterValues("checkit");
String rootvalue=request.getParameter("nmm");%>
<%try
{out.println(rootvalue+checkedValues);
}
catch(Exception e)
{
e.printStackTrace();
}%>

<%!
Document xmlDocument = null;

public void createXMLDocument(String filename)
{
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory documentBuilderFactory = null;

try
{
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
xmlDocument = documentBuilder.parse(filename);
}
catch (Exception e)
{
e.printStackTrace();

}
}


public Element getRootNode()
{
return xmlDocument.getDocumentElement();
}



public String getElementValue(Element element)
{
Node node = element.getFirstChild();
if (node != null && node.getNodeType() == Node.TEXT_NODE)
{
return node.getNodeValue();
}
return null;
}


public Element getElement(Element element, String name)
{

NodeList nL = element.getElementsByTagName(name);

for (int i = 0; i < nL.getLength(); i++)
{
Node n = nL.item(i);
if (((n.getParentNode()).getNodeName())
.equalsIgnoreCase((element.getTagName())))
{
return (Element) nL.item(i);
}
}
if (nL.getLength() == 0)
{
throw new RuntimeException("Element <" + name + "> not found");
} //end of if
return (Element) nL.item(0);

}


public Element getBodyElement(String name)
{
NodeList nL = xmlDocument.getElementsByTagName(name);
if (nL.getLength() == 0)
{
throw new RuntimeException("Element <" + name + "> not found");
} //end of if
return (Element) nL.item(0);
}


public Vector getChildElements(Element parentElement)
{
NodeList nL = parentElement.getChildNodes();
if (nL.getLength() == 0)
{
throw new RuntimeException("No child elements found");
}
Vector vElements = new Vector();
for (int i = 0; i < nL.getLength(); i++)
{
Node node = nL.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
vElements.add((Element) node);
}
}
return vElements;
}


public Vector getChildElements(Element parentElement, String name)
{
NodeList nL = parentElement.getChildNodes();
if (nL.getLength() == 0)
{
throw new RuntimeException("No child elements found");
} //end of if
Vector vElements = new Vector();
for (int i = 0; i < nL.getLength(); i++)
{
Node node = nL.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
String nodeName = trimNS(node.getNodeName());
if (nodeName.equalsIgnoreCase(name))
{
vElements.add((Element) node);
}
} //end of if
}
return vElements;

} //end of getElements(Element, String)


public Element getFirstChildElement(Element element)
{
NodeList nL = element.getChildNodes();
for (int i = 0; i < nL.getLength(); i++)
{
Node node = nL.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
return (Element) node;
}
} //end of for

throw new RuntimeException(
element.getTagName() + " does not have " + "any child elements.");
}


public String trimNS(String nameWithNS)
{
int index = nameWithNS.indexOf(":");
if (index != -1)
{
nameWithNS = nameWithNS.substring(index + 1);
}
return nameWithNS;
} //end of trimNS(String)

public String writeXML()
{
try
{
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(xmlDocument);

StreamResult result = new StreamResult(new java.io.FileOutputStream("d:\\puvvada\\jsp\\jaxb\\SecureFileconfig.xml"));
transformer.transform(source, result);
return result.getOutputStream().toString();
}
catch (Exception e)
{
throw new RuntimeException("Unable to convert the XMLDocument to String");
}
}



%>



<!------------------------------------->
<body >
<B>
<form name=samp method=post>


<%
this.createXMLDocument("d:\\puvvada\\jsp\\jaxb\\SecureFileconfig.xml");
String resources = new String();
StringBuffer fields = new StringBuffer();
StringBuffer enc = new StringBuffer();
Element rootElement = this.getRootNode();
System.out.println("root element..."+rootElement.getNodeName());
Vector vv = this.getChildElements(rootElement);
System.out.println("Total Members.."+vv.size());

for(int i=0;i<vv.size();i++)
{
Vector uris = this.getChildElements((Element)vv.elementAt(i));
System.out.println("subvector..size.."+uris.size());
for(int j=0;j<uris.size();j++) {
Element ee = (Element)uris.elementAt(j);
System.out.println("element :"+ee.getChildNodes().item(0).getNodeValue());
System.out.println("element parent :"+ee.getParentNode().getNodeName());
if(ee.getChildNodes().item(0).getNodeValue().equals("Resource")) {
System.out.println("equal");
NodeList nl=((Element) ee.getParentNode()).getElementsByTagName("Field");
for(int n=0;n<nl.getLength();n++) {
System.out.println("Reached Fileds");
for(int j1=0;j1<checkedValues.length;j1++) {
System.out.println("Nodes are -->\t"+nl.item(i).getChildNodes().item(1).getFirstChild().getNodeValue()+": "+checkedValues[j1]);
if(nl.item(i).getChildNodes().item(1).getFirstChild().getNodeValue().equals(checkedValues[j1])) {
System.out.println("Teaced :"+nl.item(i).getChildNodes().item(1).getNodeValue());
nl.item(i).getChildNodes().item(3).getFirstChild().setNodeValue("Yes");}
}
}
}
}
}
System.out.println("xml...file..."+this.writeXML());
%>


Iam sending the code.please see and tell me what may be the exception
18 years ago
JSP
String[] checkedValues=String request.getParameterValues("checkit");

the exception is comming as
[Ljava.lang.String;@1fb7cbb

what may be the problem
18 years ago
JSP
when i execdute my jsp the below exxception is comming
Ljava.lang.String;@156782
what may be the problem
please send me
18 years ago
JSP
xml
how to update the value in the xml tag
<?xml version="1.0" standalone="no"?>
<sf>
<URI ID="1">
<Res>java</Res>
<Fi>
<Name>core</Name>
<IsEncrypted>NO</IsEncrypted>
</Fi>
<Fi>
<Name>adv</Name>
<IsEncrypted>NO</IsEncrypted>
</Fi>
<Fi>
<Name>j2ee</Name>
<IsEncrypted>NO</IsEncrypted>
</Fi>
<Fi>
<Name>j2m0</Name>
<IsEncrypted>NO</IsEncrypted>
</Fi>
</URI>
<URI ID="1">
<Res>asp</Res>
<Fi>
<Name>aa0</Name>
<IsEncrypted>NO</IsEncrypted>
</Fi>
<Fi>
<Name>bb</Name>
<IsEncrypted>NO</IsEncrypted>
</Fi>
<Fi>
<Name>cc</Name>
<IsEncrypted>NO</IsEncrypted>
</Fi>
</URI>
</Sf>
this is my xml file
byusing jsp u have to populate the values in the combo.when u select avalue in the combo that correspoding values should be displayed in a table.the encryption values should have checkbox .that i have done it.now my problem is when u check some of the values and click submit the new values are submitted into the xml file.suppose when u check 2 checkboxes in encryption fields,the values yes should be updated in the xml file.

Iam sending my jsp file also


<%@ page import = "javax.xml.parsers.DocumentBuilderFactory"%>
<%@ page import = "org.w3c.dom.*"%>
<%@ page import = "javax.xml.parsers.DocumentBuilder"%>
<%@ page import = "org.xml.sax.SAXException"%>
<%@ page import = "org.xml.sax.SAXParseException"%>
<%@ page import = "javax.xml.parsers.*"%>
<%@ page import = "java.io.ByteArrayOutputStream,java.util.Vector,javax.xml.transform.Transformer,javax.xml.transform.TransformerFactory,javax.xml.transform.dom.DOMSource,javax.xml.transform.stream.StreamResult"%>



<html>
<head>
<script language="javascript">
function submitForm() {

alert(document.samp.sel.value);
var filev = document.samp.sel.value;
document.samp.action="parse.jsp?selValue="+filev;
document.samp.submit();
}
</script>
</head>

<%!
Document xmlDocument = null;

public void createXMLDocument(String sFileName)
{
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory documentBuilderFactory = null;

try
{
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
xmlDocument = documentBuilder.parse(sFileName);
}
catch (Exception e)
{
e.printStackTrace();

}
}


public Element getRootNode()
{
return xmlDocument.getDocumentElement();
}



public String getElementValue(Element element)
{
Node node = element.getFirstChild();
if (node != null && node.getNodeType() == Node.TEXT_NODE)
{
return node.getNodeValue();
}
return null;
}


public Element getElement(Element element, String name)
{

NodeList nL = element.getElementsByTagName(name);

for (int i = 0; i < nL.getLength(); i++)
{
Node n = nL.item(i);
if (((n.getParentNode()).getNodeName())
.equalsIgnoreCase((element.getTagName())))
{
return (Element) nL.item(i);
}
}
if (nL.getLength() == 0)
{
throw new RuntimeException("Element <" + name + "> not found");
} //end of if
return (Element) nL.item(0);

}


public Element getBodyElement(String name)
{
NodeList nL = xmlDocument.getElementsByTagName(name);
if (nL.getLength() == 0)
{
throw new RuntimeException("Element <" + name + "> not found");
} //end of if
return (Element) nL.item(0);
}


public Vector getChildElements(Element parentElement)
{
NodeList nL = parentElement.getChildNodes();
if (nL.getLength() == 0)
{
throw new RuntimeException("No child elements found");
}
Vector vElements = new Vector();
for (int i = 0; i < nL.getLength(); i++)
{
Node node = nL.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
vElements.add((Element) node);
}
}
return vElements;
}


public Vector getChildElements(Element parentElement, String name)
{
NodeList nL = parentElement.getChildNodes();
if (nL.getLength() == 0)
{
throw new RuntimeException("No child elements found");
} //end of if
Vector vElements = new Vector();
for (int i = 0; i < nL.getLength(); i++)
{
Node node = nL.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
String nodeName = trimNS(node.getNodeName());
if (nodeName.equalsIgnoreCase(name))
{
vElements.add((Element) node);
}
} //end of if
}
return vElements;

} //end of getElements(Element, String)


public Element getFirstChildElement(Element element)
{
NodeList nL = element.getChildNodes();
for (int i = 0; i < nL.getLength(); i++)
{
Node node = nL.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
return (Element) node;
}
} //end of for

throw new RuntimeException(
element.getTagName() + " does not have " + "any child elements.");
}


public String trimNS(String nameWithNS)
{
int index = nameWithNS.indexOf(":");
if (index != -1)
{
nameWithNS = nameWithNS.substring(index + 1);
}
return nameWithNS;
} //end of trimNS(String)

public String writeXML()
{
try
{
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(xmlDocument);
StreamResult result = new StreamResult(new ByteArrayOutputStream());
transformer.transform(source, result);
return result.getOutputStream().toString();
}
catch (Exception e)
{
throw new RuntimeException("Unable to convert the XMLDocument to String");
}
}



%>






<body bgcolor="red">
<B>
<form name=samp method=post>
<center><select name="sel" onChange="submitForm()">
<option value="0" selected>-select memberfile-</option>
<%

this.createXMLDocument("d:\\puvvada\\jsp\\ll\\SecureFileconfig.xml");
StringBuffer resources = new StringBuffer();
StringBuffer fields = new StringBuffer();
StringBuffer enc = new StringBuffer();

//System.out.println("xml...file..."+this.writeXML());
Element rootElement = this.getRootNode();


System.out.println("root element..."+rootElement.getNodeName());



Vector vv = this.getChildElements(rootElement);
System.out.println("Total Members.."+vv.size());

for(int i=0;i<vv.size();i++)
{
Vector uris = this.getChildElements((Element)vv.elementAt(i));
System.out.println("subvector..size.."+uris.size());
for(int j=0;j<uris.size();j++)
{
if(j==0)
{
Element ee = (Element)uris.elementAt(0);
%>

<option value=<%=this.getElementValue(ee)%>><%=this.getElementValue(ee)%></option>
<%



}
else
{
Vector last = this.getChildElements((Element)uris.elementAt(j));
fields.append(this.getElementValue((Element)last.get(0)));
fields.append("[[]]");
enc.append(this.getElementValue((Element)last.get(1)));
enc.append("[[]]");
}


}

}


%>





</select>
</center>
</form>
<center>
<table width=50% height=50%>
<tr><th>Sno</th><th>FieldName</th><th>EncryStatus</th></tr>
<%
String reqvalue = request.getParameter("selValue").toString();
System.out.println(reqvalue);
if(reqvalue !=null)
{
if(!(reqvalue.equals("0")))
{

for(int i=0;i<vv.size();i++)
{
Vector uris = this.getChildElements((Element)vv.elementAt(i));
System.out.println("subvector..size.."+uris.size());
for(int j=1;j<uris.size();j++)
{

Element ee = (Element)uris.elementAt(0);

if(this.getElementValue(ee).equals(reqvalue))
{
Vector last = this.getChildElements((Element)uris.elementAt(j));
%>

<tr><td><%=j%></td><td><%=this.getElementValue((Element)last.get(0))%></td><td><%=this.getElementValue((Element)last.get(1))%><input type=checkbox></td></tr>


<%}

}

}





}
}
%>
</table>

</center>

</html>
please send this .atlest tellme how to updatethe value in the xml file
setting up log4j in weblogic7.0
18 years ago
dom
sample program to retreive the value,given the tagname
I Have the problem in weblogic deployment as
weblogic.management.ManagementException,
please tell me what may be the solution
18 years ago