*
The moose likes JSP and the fly likes java.lang.string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

java.lang.string

subrahm puvvada
Greenhorn

Joined: Aug 23, 2005
Posts: 14
when i execdute my jsp the below exxception is comming
Ljava.lang.String;@156782
what may be the problem
please send me
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Doesn't look like exception.
I gues you trying to print array. Could you post code?


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
subrahm puvvada
Greenhorn

Joined: Aug 23, 2005
Posts: 14
<%@ 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
Khan Malamir
Greenhorn

Joined: Sep 09, 2005
Posts: 16
The exception must have appeared somewhere - in logs or in server console.
I suspect this code:

This is a guaranteed error, but I wonder why you did not get a compile error when the JSP was compiled. You don't even need that cast since getParameterValues(...) already returns a String[].
subrahm puvvada
Greenhorn

Joined: Aug 23, 2005
Posts: 14
sorry i have given there stringarray only not string.
i have forgotten to modify and posted
Khan Malamir
Greenhorn

Joined: Sep 09, 2005
Posts: 16
Then please do search logs and traces for exception informations, also you can add System.out.println(...) statements in your code to locate the code that generates the exception. I doubt we can help you without additional information.
Khan Malamir
Greenhorn

Joined: Sep 09, 2005
Posts: 16
It seems you got answer in your other thread. Posting several threads for the same thing is bad practice because you waste other people's time.
Please take the time to read the CarefullyChooseOneForum of 'how to ask'.
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
As I have said in another post by you for the same issue, you do not get an Exception. You have printed out the String[].

out.println(rootvalue+checkedValues);


This prints the address of the String[] "checkedValues" and not the elements.


keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Please do not cross-post the same question in in the same or across multiple forums. It wastes people's time when multiple redundant conversations take place.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.string