Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.string

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
when i execdute my jsp the below exxception is comming
Ljava.lang.String;@156782
what may be the problem
please send me
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Doesn't look like exception.
I gues you trying to print array. Could you post code?
 
subrahm puvvada
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
<%@ 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
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
sorry i have given there stringarray only not string.
i have forgotten to modify and posted
 
Khan Malamir
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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'.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic