Please Help : (x)newInstance()
I want to load class and instantiate object, but i dont i now the type of object :
my code java is :
Class cls = class.forName(org.com.xxxx);
int idx0 = str.lastIndexOf(".");
String testObj = str.substring(idx0+1);
obj = (testObj)cls.newInstance();
when i compile exception is : class testObj introuvable
Please Help Thanks
My code is (i dont use interface in my case.......):
HashMap ht_ = getAttribute (root, hsAll_);
Set s_ = ht_.keySet();
for (Iterator i= s_.iterator(); i.hasNext(); ) {
String str = (String)i.next();
int idx0 = str.lastIndexOf(".");
String testObj = str.substring(idx0+1);
HashMap htt_ = (HashMap)ht_.get(str);
Set ss_ = htt_.keySet();
Class cls = Class.forName(str);
o_ = (testObj)cls.newInstance();
for (Iterator ii= ss_.iterator(); ii.hasNext(); ) {
String nomAtt = ((String)ii.next());
String test = (nomAtt.substring(3));
String valAtt = (String)htt_.get(nomAtt);
//Tableau des classes des param�tres des m�thodes
Class[] args = new Class[1] ;
//R�cup�ration du type des param�tres des m�thdes de l'objet
String clsField = cls.getDeclaredField(test.toUpperCase()).getType().toString();
int idx = clsField.lastIndexOf(".");
String strField = clsField.substring(idx+1);
//Tableau des objets � passer en param�tre(chaque type doit
//�tre envelopper dans un objet qui lui correspond(double----> Double))
Object[] parms = new Object[1] ;
if(strField.equals("String") ){
parms[0] = valAtt;
args[0] = Class.forName("java.lang.String");
method = cls.getMethod(nomAtt,args);
else if(clsField.equals("double")){
parms[0] = new Double(valAtt);
method = cls.getMethod(nomAtt,new Class[] {double.class});
else if(clsField.equals("int")){
parms[0] = new Integer(valAtt);
method = cls.getMethod(nomAtt,new Class[] {int.class});
else if(clsField.equals("boolean")){
parms[0] = new Boolean(valAtt);
method = cls.getMethod(nomAtt,new Class[] {boolean.class});
else if(clsField.equals("float")){
parms[0] = new Float(valAtt);
method = cls.getMethod(nomAtt,new Class[] {float.class});
else if(clsField.equals("DateOms")){
dateoms = new DateOms(valAtt,"dd-MM-yyyy");
else continue;
//Appel de la m�thode envelopp�e dans l'objet method avec le param�tre params
method.invoke(o_,parms);
if (TraceManager.on()) {
TraceManager.log ("Le vecteur g�n�r� est de taille : " + htsObj.size());
//Stockage de l'objet instanci� dans un HashMap
htsObj.put(testObj, o_);
htsObj.put("DateOms", dateoms);
catch (Exception ex) {
TraceManager.log ("Le vecteur d'objet est null ");
ex.printStackTrace();
if (TraceManager.on()) {
TraceManager.log ("Fin de la m�thode xmlToObj()");
return htsObj;
}
Similar Messages
-
NewInstance from variable class(Please Help)
I want to generate an object from xml
example :
<com.toto.titi.variable>
<name>tata</name>
<age>20</age>
</com.toto.titi.variable>
my java code :
str = "com.toto.titi.variable" ;
int idx0 = str.lastIndexOf(".");
String testObj = str.substring(idx0+1);
Class cls = Class.forName(str);
o_ = (testObj)cls.newInstance(); //testObj it's variable, i dont now origin class or Interface
this code is not work
Please help
Thanksdo a search on here for "beanbox"....that shows how to do object persistence and creation using xml.
-
How to include a static file.... Please help..
Hi guys..
i am going crazy here, so please help.... is it possible to use <jsp:include page="headlines.html" flush="true"/> to serve a static file( headlines.html) which is in say tomcat_home\bin.. also, i wonder why the following code creates a headline file in the bin folder in the first place.. i thought, it should create headlines.html in the same folder as this class...i am a newbie as you can see...thanks in advance
package beanpackage;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.io.FileOutputStream;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import java.io.File;
public class RSSProcessor {
public RSSProcessor(){ }
String _RSSFile;
public String getRSSFile(){
return _RSSFile;
public void setRSSFile(String fileName){
try {
StreamSource source = new StreamSource(fileName);
StreamSource finalStyle = new StreamSource("final.xsl");
String outputURL = "headlines.html";
StreamResult result = new StreamResult(new
FileOutputStream(outputURL));
TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer transformer = transFactory.newTransformer(finalStyle);
transformer.transform(source, result);
} catch (Exception e) {
e.printStackTrace();
}I am just about there thanks to you stibrian..
as you know that i am using a bean and a jsp to transform the rss feed.. following your direction i used String filePath = getServletContext().getRealPath etc. in my JSP and i am getting my headlines.html in the ROOT folder every time i reload the JSP.. thats great ! but my <jsp:include page="headlines.html" flush="true"/> is still not working(i tried every possible combination).. is there any thing wrong? I will post my new code below and i hope that i would not bother you again (on this:-).. thanks a lot.. also, i will add some dukes to this question, as a thank you..
package beanpackage;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.io.FileOutputStream;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import java.io.File;
import java.io.*;
public class RSSProcessor {
public RSSProcessor(){ }
String _RSSFile;
public String getRSSFile(){
return _RSSFile;
public void setRSSFile(String fileName, String outputURL){
try {
StreamSource source = new StreamSource(fileName);
StreamSource finalStyle = new StreamSource("final.xsl");
//String outputURL = getServletContext().getRealPath("WEB-INF" + File.separator + "headlines.html");
//String outputURL = "headlines.html";
StreamResult result = new StreamResult(new
FileOutputStream(outputURL));
TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer transformer = transFactory.newTransformer(finalStyle);
transformer.transform(source, result);
} catch (Exception e) {
e.printStackTrace();
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<jsp:useBean id="rssBean" scope="request" class="beanpackage.RSSProcessor">
<%@ page import="java.io.File"%>
<%String outputURL = getServletContext().getRealPath(File.separator + "headlines.html");%>
<%
rssBean.setRSSFile("http://www.rediff.com/rss/inrss.xml", outputURL);
%>
</jsp:useBean>
<html>
<head>
<title>Syndicated Feeds</title>
</head>
<body>
<jsp:include page="headlines.html" flush="true"/>
</body>
</html> -
Can't run very simple DOM parsing source on my machine - please help :(
Hi Guys,
I am trying to run the following very simple program on my machine to parse a very simple XML file.
It just returns Document object NULL.
Same code is working fine on another machine.
Note: there is no silly mistake. i have valid xml file at valid place.
Please help.
import org.apache.xerces.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import java.io.*;
class XML
public static void main(String[] args)
try{
String caseFile = "c:\\case-config\\config.xml";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(caseFile);
System.out.println("\n\n----" + doc);
}catch(Exception e)
e.printStackTrace();
}You could also work with JDOM, which I find easier to use than regular DOM:
import org.xml.sax.InputSource;
import java.io.FileReader;
import org.jdom.input.SAXBuilder;
import org.jdom.Document;
String caseFile = "c:/case-config/config.xml";
InputSource inputSource = new InputSource(new FileReader(caseFile));
SAXBuilder builder= new SAXBuilder();
Document document = builder.build(inputSource);Just an alternate suggestion. -
Return Data from Oracle using a web service in AXIS - please help
Hi Forum,
I am very new to web services and Java tech. and recently I have been assigned to work with technology and I am struggling to learn it and need your help and assistance.
I am trying to return some data from a an oracle database but I have to do that using a web service and I am using AXIS. For example below is a simple program that returns two columns for the demo EMP table
import java.sql.*;
class emp {
public static void main(String args[])
throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
// or you can use:
// DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott", "tiger");
Statement stmt = conn.createStatement( );
ResultSet rset = stmt.executeQuery("select * from emp");
while(rset.next( )) {
System.out.println(rset.getString(1));
System.out.println(rset.getString(2));
rset.close( );
stmt.close( );
conn.close( );
} but I do not know how to convert this into a web service.
Please help.
Thanks in advance.
Regards,
RaviThe following code returns Document. I will be calling the below function to convert my Resultset to document. In my JWS file i simply call a method with parameters. can a web service method in .jws file return Document type. It shows error will doing so. Please help me.
public static Document toDocument(ResultSet rs) throws ParserConfigurationException, SQLException
Document res_doc = null;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
Element results = doc.createElement("Results");
doc.appendChild(results);
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount();
while (rs.next())
Element row = doc.createElement("Row");
results.appendChild(row);
for (int i = 1; i <= colCount; i++)
String columnName = rsmd.getColumnName(i);
Object value = rs.getObject(i);
Element node = doc.createElement(columnName);
node.appendChild(doc.createTextNode(value.toString()));
row.appendChild(node);
return res_doc;
} -
Please help with SSL POST: Servlet returns Error 500
I am struggling for many days to get a Java program to log in to an SSL page. The program is supposed to track ADSL usage statistics from https://secure.telkomsa.net/titracker/, but I never seem to get around Server returned Error 500.
Could anyone please help me understand what I am doing wrong by looking at the method I used. (It seems on the server side it is a jsp servlet that handles authentication).
Any help is deeply appreciated!
I copy-paste the method directly from NetBeans:
CODE>
void connectHTTPS(String url){
try {
URL page = new URL(url); // login page necessary to get a jsp session cookie
//------------ SET UP SSL - is it right?
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
try {
//if we have the JSSE provider available,
//and it has not already been
//set, add it as a new provide to the Security class.
final Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider");
if( (null != clsFactory) && (null == Security.getProvider("SunJSSE")) )
Security.addProvider((Provider)clsFactory.newInstance());
} catch( ClassNotFoundException cfe ) {
throw new Exception("Unable to load the JSSE SSL stream handler." +
"Check classpath." + cfe.toString());
URLConnection urlc = page.openConnection();
urlc.setDoInput(true);
*Get the session id cookie set by the TelkomInternet java server
String cookie = urlc.getHeaderField("Set-Cookie");
//textpane.setText(totextpane);
textpane.setText(cookie);
//---------------- form an auth request and post it with the cookie
String postdata =URLEncoder.encode("ID_Field","UTF-8")+"="+URLEncoder.encode("myusrname","UTF-8")+"&"+URLEncoder.encode("PW_Field","UTF-8")+"="+URLEncoder.encode("mypwd","UTF-8")+"&"+URLEncoder.encode("confirm","UTF-8")+"="+URLEncoder.encode("false","UTF-8");
// set the servlet that handles authentication as target
URL page2 = new URL("https://secure.telkomsa.net/titracker/servlet/LoginServlet");
// cast to httpConn to enable setRequestMethod()
HttpURLConnection urlc2 = (HttpURLConnection)page2.openConnection();
// formulate request with POST data urlc2.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
urlc2.setRequestMethod("POST"); // experimental
urlc2.setRequestProperty("Content-Length",""+postdata.length());
urlc2.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)");
urlc2.setRequestProperty("Accept-Language","en-us");
urlc2.setUseCaches(false);
urlc2.setDoOutput(true);
urlc2.setDoInput(true);
urlc2.setFollowRedirects(true); // ??
//send cookies
urlc2.setRequestProperty("Set-Cookie", cookie); // or "Cookie" - doesn't work either
//write other data
PrintWriter out = new PrintWriter(urlc2.getOutputStream());
out.print(postdata); // username and password here
out.flush();
out.close();
//---------------- get the authenticated page with real ADSL statistics
BufferedReader br = new BufferedReader(new InputStreamReader(urlc2.getInputStream()));
String totextpane = "";
String buffer = "";
while (buffer != null) {
try {
totextpane = totextpane + "\n" + buffer;
buffer = br.readLine();
} catch (IOException ioe) {
ioe.printStackTrace();
break;
textpane.setText(totextpane);
} catch (Exception ex) {
System.err.println(ex.getMessage());
---- END CODE---
Thank you very much for any attempt at helping with this problem!I am struggling for many days to get a Java program to log in to an SSL page. The program is supposed to track ADSL usage statistics from https://secure.telkomsa.net/titracker/, but I never seem to get around Server returned Error 500.
Could anyone please help me understand what I am doing wrong by looking at the method I used. (It seems on the server side it is a jsp servlet that handles authentication).
Any help is deeply appreciated!
I copy-paste the method directly from NetBeans:
CODE>
void connectHTTPS(String url){
try {
URL page = new URL(url); // login page necessary to get a jsp session cookie
//------------ SET UP SSL - is it right?
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
try {
//if we have the JSSE provider available,
//and it has not already been
//set, add it as a new provide to the Security class.
final Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider");
if( (null != clsFactory) && (null == Security.getProvider("SunJSSE")) )
Security.addProvider((Provider)clsFactory.newInstance());
} catch( ClassNotFoundException cfe ) {
throw new Exception("Unable to load the JSSE SSL stream handler." +
"Check classpath." + cfe.toString());
URLConnection urlc = page.openConnection();
urlc.setDoInput(true);
*Get the session id cookie set by the TelkomInternet java server
String cookie = urlc.getHeaderField("Set-Cookie");
//textpane.setText(totextpane);
textpane.setText(cookie);
//---------------- form an auth request and post it with the cookie
String postdata =URLEncoder.encode("ID_Field","UTF-8")+"="+URLEncoder.encode("myusrname","UTF-8")+"&"+URLEncoder.encode("PW_Field","UTF-8")+"="+URLEncoder.encode("mypwd","UTF-8")+"&"+URLEncoder.encode("confirm","UTF-8")+"="+URLEncoder.encode("false","UTF-8");
// set the servlet that handles authentication as target
URL page2 = new URL("https://secure.telkomsa.net/titracker/servlet/LoginServlet");
// cast to httpConn to enable setRequestMethod()
HttpURLConnection urlc2 = (HttpURLConnection)page2.openConnection();
// formulate request with POST data urlc2.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
urlc2.setRequestMethod("POST"); // experimental
urlc2.setRequestProperty("Content-Length",""+postdata.length());
urlc2.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)");
urlc2.setRequestProperty("Accept-Language","en-us");
urlc2.setUseCaches(false);
urlc2.setDoOutput(true);
urlc2.setDoInput(true);
urlc2.setFollowRedirects(true); // ??
//send cookies
urlc2.setRequestProperty("Set-Cookie", cookie); // or "Cookie" - doesn't work either
//write other data
PrintWriter out = new PrintWriter(urlc2.getOutputStream());
out.print(postdata); // username and password here
out.flush();
out.close();
//---------------- get the authenticated page with real ADSL statistics
BufferedReader br = new BufferedReader(new InputStreamReader(urlc2.getInputStream()));
String totextpane = "";
String buffer = "";
while (buffer != null) {
try {
totextpane = totextpane + "\n" + buffer;
buffer = br.readLine();
} catch (IOException ioe) {
ioe.printStackTrace();
break;
textpane.setText(totextpane);
} catch (Exception ex) {
System.err.println(ex.getMessage());
---- END CODE---
Thank you very much for any attempt at helping with this problem! -
URLClassLoader - with JAR Files- - - Please Help
Hi all,
I have two seperate JAR files which contain same files but different progressive versions.JAR 1 is version V1 and JAR 2 is Version V1.1
I have a program which loads classes from these two JARS and runs certain comparsions on them.CODE IS SHOWN and SO is ERROR.PLEASE HELP and ADVISE.Im on a UNix box using JDK 1.3.
CODE:
====
1.In my main i define the TWO JARS PATHS and the item to compare called ENTITYNAME as:
String jarFile1 = "/xenv/GFINet_Java/6.2_Z1/1.3.X/gfinet_entities.jar";
String jarFile2 = "/xenv/GFINet_Java/6.1_Y1/1.3.X/gfinet_entities.jar";
String entityName = "gfinet.entities.GFIBasketEntity";
2.Then i call the function
EntityVersionComparator evc = new EntityVersionComparator();
evc.test(jarFile1, jarFile2, entityName);
3.Test function loads the JARS
private void test(String jarFile1, String jarFile2, String entityName) throws Exception {
URLClassLoader jar1 =
(URLClassLoader)newClassLoader(jarFile1);
URLClassLoader jar2 =
(URLClassLoader)newClassLoader(jarFile2);
4. Load that item ENTITYNAME FROM JAR.
// load GFIBasketEntity from Jar1
GFIBaseEntity ent1 =
(GFIBaseEntity)loadClass(jar1, entityName).newInstance();
PROBLEM ERRORS:
==============
Exception in thread "main" java.net.MalformedURLException : no
protocol :/xenv/GFINet_Java/sun4/6.2.Z2/Solaris8/3.3.2/1.3.X/lib/gfinet_entities.jar
at java.net.URL.<init>(URL.java:473)
at java.net.URL.<init>(URL.java:376)
at java.net.URL.<init>(URL.java:330)
at EntityVersionComparator.newClassLoader(EntityVersionComparator.java:143)
at EntityVersionComparator.test(EntityVersionComparator.java:88)
at EntityVersionComparator.main(EntityVersionComparator.java:74)
WHATS GOING ON..Is there something wrong with the path?Pls advise
jasonI also in my CODE have:
private ClassLoader newClassLoader(String path)
throws MalformedURLException
{ URL url = new URL(path);
return new URLClassLoader(new URL[]url); -
Want to run the servlet (please help me)
Hello Guys, I'm very new to java, I have downloaded the tomcat's servlets runner, and could able to write servlets and then could able to compile them without any errors, but the major problem is I'm not at all able to run them, first of all I dont know where shall I put the comiled servlet.class files, and I'm starting the Tomcats http server, and it is not picking up my servlets, could u please specify in whcih directory should I place my compiled servlets,
with regards,
shabeer.Hello Ajit, well I have read all the documentation and I have run all the example servlets in Tomcat, but the problem is my oracle server is listening at 8080 port so I have given a different port number(2002) to tomcat while installation, im using(http://localhost:2002/examples/servlet/MyFirstServlet) and I have placed my compiled servlet in the classes file and trying to access it, Tomcats HTTP server is recognising the servlet but it is giving some exception, I think it is saying something about configuration, do I need to make any changes in the server.xml file please advice me...here is the error what it says on the browser servlet exception....
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot allocate servlet instance for path /examples/servlet/MyFirstServlet
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:427)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:471)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:536)
root cause
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class MyFirstServlet with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
at java.lang.Class.newInstance0(Class.java:300)
at java.lang.Class.newInstance(Class.java:259)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:892)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:658)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:408)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:471)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:536)
Apache Tomcat/4.1.12
please help me -
What is wrong with this!! please help
Hello friends,
I'm a learner and I have done lot of JDBC connectivity with Acess database, and now I want to connect java program with oracle database, but the problem is I have downloaded the oracle driver, set the classpath, and I have created the DataSource Name with MS-ODBC, I could able to compile but I'm getting run time exception, please help me with this. regards, shabeer.
the program is
import java.sql.*;
public class ShabeerJdbc {
public static void main(String args[]) {
// String url = "jdbc:oracle:thin:@imran:3339:shabeerjdbc";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";
Statement stmt;
try {
System.out.println("shabeer1");
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
System.out.println("shabeer2");
} catch(java.lang.Exception e) {
System.out.println("shabeer3");
System.err.print("ClassNotFoundException: ");
System.out.println("shabeer4");
System.err.println(e.getMessage());
try {
System.out.println("shabeer55");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:shabeerjdbc", "system", "mehar");
System.out.println("shabeer6");
stmt = con.createStatement();
System.out.println("shabeer7");
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
the run time error is ......
C:\JavaPractice>java ShabeerJdbc
shabeer1
shabeer2
shabeer55
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Savepoint
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ShabeerJdbc.main(ShabeerJdbc.java:38)
****************************************HI Deriderj, thanks for your response, well I have changed the Datasourse name to SID which is "Imran" and still it is not working....do I need to download anymore driver or whether they be bundled with the ojdbc.jar, please advice me. What if I want to use another driver as you mentioned...not to use thin: what other drivers will be available for the Oracle9.2.0.1.0 please advice me, thanks a lot
My SID name is "Imran"
listening port is is 1521
odbc datasource name is "shabeerjdbc"
I'm a very biginner and I'm facing too much problem, please help me. Well I have got Oracle9.2.0.1.0 loaded as the database and soon after I intstalled it I have copied ojdbc14.jar into my java classpath and I'm trying to connect to this data base. I dont know what driver I should use, neither I downloaded any. I'm just mentioning thin: in my URL. But It is giving error, can u please tell me what driver should I mention in the URL, and why I'm getting this error, Here is the code that is compiling without errors.
import java.sql.*;
public class ShabeerJdbc {
public static void main(String args[]) {
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";
Statement stmt;
try {
System.out.println("shabeer1");
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
System.out.println("shabeer2");
} catch(java.lang.Exception e) {
System.out.println("shabeer3");
System.err.print("ClassNotFoundException: ");
System.out.println("shabeer4");
System.err.println(e.getMessage());
try {
System.out.println("shabeer55");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:Imran", "system", "mehar");
System.out.println("shabeer6");
stmt = con.createStatement();
System.out.println("shabeer7");
stmt.executeUpdate(createString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("Sql Exception" + ex.getMessage());
************The runtime Error it is giving is *********************
C:\JavaPractice>java ShabeerJdbc
shabeer1
shabeer2
shabeer55
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Savepoint
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ShabeerJdbc.main(ShabeerJdbc.java:38)
***************************** please help me.... -
Can't decode JSP Server Error Please help!
Hi,
I wrote this code and I get this huge server error when I run it and I can't for the life of me figure out what's wrong, can someone please help me debug my jsp or explain to me what any of those errors mean?
Here is the error message:
type Exception report
message
description
The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
root cause
java.lang.NullPointerException
at org.apache.jsp.Pdb_Add_jsp._jspService(Pdb_Add_jsp.java:530)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
Apache Tomcat/4.1.24
Here is the code: Pdb_Add.jsp
<%@ include file="authenticate.jsp" %>
<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://localhost:3306/xxxxx?user=****&password=***";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html>
<head>
<title>Project Portal Confirm New Project</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
<link type="text/css" rel="stylesheet" href="xtree.css">
<script src="xtree.js"></script>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<table bgcolor="#ffffff" width="761" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="337" valign="top">
<table width="761" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="11" valign="top"><IMG height=1 src="images/spacer.gif" width=1></td></tr>
<tr>
<td height="291" valign="top">
<table width="761" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"><IMG height=1 src="images/spacer.gif" width=1></td>
<td width="399" valign="top">
<table width="399" border="0" cellspacing="0" cellpadding="0">
<TBODY>
<tr><!--IMAGE SQUARE ONE: TOP -->
<td height="300" background="images/BB7250.jpg"><IMG height=1 src="images/spacer.gif" width="100%"></td>
</tr>
<tr>
<td height="0" valign="top">
<table width="300" height="200" border="0" cellpadding="0" cellspacing="0">
</tr>
</table>
</td>
</tr>
<tr></tr>
</table>
</td>
<td width="340" valign="top">
<table width="340" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="91" valign="top">
<table width="340" height="88" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="3"><IMG height=1 src="images/spacer.gif" width=1></td>
<td width="167" valign="top" background="images/S1.gif">
<table width="167" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80"> </td>
<td width="86" valign="top" class="text2" style="PADDING-TOP: 24px"></td>
</tr>
</table>
</td>
<td width="3"><IMG height=1 src="images/spacer.gif" width=1></td>
<td width="167" valign="top" background="images/V.gif">
<table width="167" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70"> </td>
<td width="95" valign="top" class="text2" style="PADDING-TOP: 23px"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="88" valign="top">
<table width="340" height="88" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="3"><IMG height=50 src="images/spacer.gif" width=1></td>
<td width="77" valign="top" background="images/and.gif">
<table width="167" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80"> </td>
<td width="86" valign="top" class="text2" style="PADDING-TOP: 21px"></td>
</tr>
</table>
</td>
<td width="3"><IMG height=1 src="images/spacer.gif" width=1></td>
<td width="167" valign="top" background="images/V.gif">
<table width="167" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="77"> </td>
<td width="90" valign="top" class="text2" style="PADDING-TOP: 21px"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" style="PADDING-LEFT: 4px">
<table width="336" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="300" height="4" valign="top" background="images/spacer.gif">
</td>
</tr>
<tr>
<td width="300" height="116" valign="top" background="images/portalspiral.jpg">
</td>
</tr>
</table>
</td>
</tr>
</table></td>
<td><IMG height=1 src="images/spac" width=1></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top">
<table width="761" height="35" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10" valign="top"> </td>
<td width="517" valign="top">
<table width="517" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<table width="517" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="3" bgcolor="#000000">
<IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
<tr>
<td valign="top">
<table width="250" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="75" valign="top">
<A href="PIndex.html"><IMG height=31 src="images/but2.gif" width=99 border=0></A></td>
<td width="80" valign="top" style="PADDING-RIGHT: 1px">
<A href="ProjectPortal_Add.html"><IMG height=31 src="images/but3.gif" width=104 border=0></A></td>
<td width="100" valign="top" style="PADDING-RIGHT: 6px">
<A href="index-2.html"><IMG height=31 src="images/but4.gif" width=104 border=0></A></td>
<td width="100" valign="top">
<A href="PDir.html"><IMG id=IMG1 height=31 src="images/but5.gif" width=134 border=0 ></A></td>
<td width="75" valign="top">
<A href="index-4.html"><IMG height=31 src="images/but6.gif" width=99 border=0></A></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="1" bgcolor="#e3e3e3">
<IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
</table></td>
<td width="150" valign="top">
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="3" bgcolor="#000000"><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
<tr>
<td height="1"><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
<tr>
<td height="31" valign="top">
<table width="150" height="31" border="0" cellpadding="0" cellspacing="0" background="images/spacer.gif" bgcolor="#ffffff">
<tr>
<td width="80" valign="top" style="PADDING-TOP: 7px"><IMG height=25 src="images/spacer.gif" width=56></td>
<td width="100" valign="top" style="PADDING-RIGHT: 4px; PADDING-TOP: 8px"
><input name="textfield" class="form" ></td>
<td valign="top" style="PADDING-TOP: 5px">
<A href="#"><IMG height=21 src="images/minis.gif" width=20 border=0></A></td>
</tr>
</table></td>
</tr><tr>
<td height="1" bgcolor="#e3e3e3"><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
</table></td>
<td><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
</table></td>
</tr>
</table></TD></TR>
<tr>
<td height="362" valign="top">
<table width="761" height="362" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="218" valign="top">
<table width="218" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12" valign="top">
<IMG height=1 src="images/spacer.gif" width=1></td>
<td width="218" valign="top">
<table width="218" border="0" cellspacing="0" cellpadding="0" style="WIDTH: 218px; HEIGHT: 472px">
<tr>
<td width="12" valign="top"><IMG height=1 src="images/spacer.gif" width=1></td>
<td width="205" valign="top">
<IMG alt="" src="file://C:\Documents and Settings\atavakkolie\Desktop\Project Portal\images\PDir.gif"
id=IMG1
>
<DIV id=DIV1
style="PADDING-RIGHT: 5px; PADDING-LEFT: 15px; LEFT: 5px; PADDING-BOTTOM: 5px; OVERFLOW: auto; WIDTH: 200px; PADDING-TOP: 0px; POSITION: relative; TOP: 10px; HEIGHT: 100%"><!-- js file containing the tree content, edit this file to alter the menu,
the menu will be inserted where this tag is located in the document -->
<SCRIPT src="tree.js"></SCRIPT>
</DIV></td>
<td>
</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="1" valign="top"><table width="1" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="2"><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
<tr>
<td height="920" bgcolor="#e3e3e3"><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
<tr>
<td height="2"><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
</table></td>
<td width="542" valign="top">
<table width="542" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="530" valign="top">
<table width="530" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<table width="530" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="41" valign="top" style="PADDING-TOP: 6px"><IMG id=IMG1
style="LEFT: 409px; TOP: 552px" height
=44 src="images/Addp.gif" width=207></td>
</tr><!-- Form starts here-->
<tr>
<td valign="top"
>
<table width="530" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="text" style="PADDING-LEFT: 18px">
<!-- ***** START EDITABLE REGION -->
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
String name = request.getParameter("name");
String email = request.getParameter("email");
String pname = request.getParameter("pname");
String pmanager = request.getParameter("pmanager");
String svvpp = request.getParameter("svvpp");
String pdphase = request.getParameter("pdphase");
String pdptarget = request.getParameter("pdptarget");
String etimecode = request.getParameter("etimecode");
if( request.getParameter("name").equals("") || request.getParameter("email").equals("") || request.getParameter("pname").equals("")
|| request.getParameter("pmanager").equals("") || request.getParameter("svvpp").equals("") || request.getParameter("pdphase").equals("")
|| request.getParameter("pdptarget").equals("") || request.getParameter("etimecode").equals(""))
out.println("<b>ERROR:</b> All fields were not filled out. Please go back and try again.");
else
try
int retval = statement.executeUpdate("INSERT INTO project VALUES('" + name + "," + email + "," + pmanager + "," + svvpp + "," + pname + "," + pdphase + "," + pdptarget + "," + etimecode + "')");
out.println("<b>SUCCESS:</b> Your changes have been successfully written to the database.");
session.putValue("entry", "<b>" + pname + " (Add Project)</b>: added user with email: " + email + ", pmanager: " + pmanager + ", svvpp: " + svvpp + ", pdphase: " + pdphase + ", pdptarget: " + pdptarget + ", etimecode: " + etimecode);
%>
<jsp:include page="log.jsp" />
</jsp:include>
<%
catch (SQLException e)
if (e.getErrorCode() == 1062)
{ out.println("<p><b>ERROR:</b> There is something wrong. Please go back and try again.</p>");
else
out.println("<p><b>ERROR:</b> Unexpected error <b>" + e.getErrorCode() + "</b> occurred.</p>");
out.println("<p>" + e + "</p>");
%>
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="12"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="71" valign="top"><table width="761" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table width="761" height="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="13">
<IMG height=1 src="images/spacer.gif" width=1></td>
<td width="738" align="middle" background="images/back_4.gif" bgcolor="#808080" class="links">
<A class=links href="index.html"><strong> Home page</strong></A>
| <A class=links href="index-1.html"><strong>About us</strong></A>
| <A class=links href="index-2.html"><strong>Search</strong></A>
| <A class=links href="index-3.html"><strong> Contact</strong></A>
| <A class=links href="#"><strong>SV&V Links</strong></A>
| <A class=links href="index-4.html"><strong>Help</strong></A>
| <A class=links href="#"><strong>Site map</strong></A>
| <A class=links href="#"><strong>Links</strong></A></td>
<td width="10">
<IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
</table></td>
</tr>
<tr>
<td height="18" valign="top"><IMG height=1 src="images/spacer.gif" width=1></td>
</tr>
<tr>
<td align="middle" valign="top" class="copy">
<A class=copy style="TEXT-DECORATION: none" href="index-5.html" >Copyright 2004-2005 � SV&V Project Portal. All rights reserved.</A></td>
</tr>
</table></td>
</tr></TBODY></TABLE></TABLE>
</body>
<script>
function addNode() {
if (tree.getSelected()) {
tree.getSelected().add(new WebFXTreeItem('New'));
function addNodes() {
if (tree.getSelected()) {
var foo = tree.getSelected().add(new WebFXTreeItem('New'));
var bar = foo.add(new WebFXTreeItem('Sub 1'));
function delNode() {
if (tree.getSelected()) {
tree.getSelected().remove();
</script>
</html>request.getParameter("name").equals("")You are using this in your 'if' statement. But if a parameter by the name "name" is not found, it would return a null reference and calling equals() would call a NullPointerException.
I observed that you are already assigning those parameters to Strings. You should add null checking for each of them. :) -
Making a SOAP call through a proxy! Please help!!!
I'm behind a firewall. I've checked most of the posting in the forum and on the Internet. Most get by using the java.net.Authenticator class, and setting default properties such as https.proxyHost, https.proxyUserName, https.proxyPassword etc. I've tried all that!!! Still doesn't work.
Here's the error msg I get:
Required
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown
Source)
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedP
ost.run(Unknown Source)
... 4 more
javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml
.soap.SOAPException: Bad response: (407Proxy Authentication Required
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown
Source)
at GoogleJPClient.sendGoogJMsg(GoogleJPClient.java:103)
at GoogleJPClient.main(GoogleJPClient.java:149)
Caused by: java.security.PrivilegedActionException: javax.xml.soap.SOAPException
: Bad response: (407Proxy Authentication Required
at java.security.AccessController.doPrivileged(Native Method)
... 3 more
Caused by: javax.xml.soap.SOAPException: Bad response: (407Proxy Authentication
Required
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown
Source)
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedP
ost.run(Unknown Source)
... 4 more
Attached is my code snippet:
========================================================================
public class GoogleJPClient
private static final String DEFAULT_HOST_URL =
"http://api.google.com/search/beta2";
private static final String URI = "urn:doGoogleSearch";
//Member variables
private String m_hostURL;
public GoogleJPClient(String hostURL) throws Exception
m_hostURL = hostURL;
public class pAuth extends Authenticator
protected PasswordAuthentication getPasswordAuthentication()
String uname = "apnt\\soolu01";
String pw = "boromir";
return new PasswordAuthentication(uname, pw.toCharArray());
public void sendGoogJMsg()
try
Properties props = new Properties();
props.setProperty("com.sun.xml.registry.https.proxyHost", "proxy_server");
props.setProperty("com.sun.xml.registry.https.proxyPort", "80");
props.setProperty("com.sun.xml.registry.https.proxyUserName", "a-user");
props.setProperty("com.sun.xml.registry.https.proxyPassword", "a-passwd");
javax.xml.soap.SOAPConnectionFactory scf =
javax.xml.soap.SOAPConnectionFactory.newInstance();
javax.xml.soap.SOAPConnection conn = scf.createConnection();
//conn.setProperties(props);
//Get instance of MessageFactory class
javax.xml.soap.MessageFactory mf =
javax.xml.soap.MessageFactory.newInstance();
//Create message from the message factory, already containing
//SOAP part
javax.xml.soap.SOAPMessage message = mf.createMessage();
//.Get the message's SOAP part
javax.xml.soap.SOAPPart soapPart = message.getSOAPPart();
//Populate msg with Google template
StreamSource prepMsg = new StreamSource(new FileInputStream("doGoogleSearchmod.xml"));
soapPart.setContent(prepMsg);
message.saveChanges(); //save changes
//fingers crossed
java.net.Authenticator.setDefault(new pAuth());
//Properties props = System.getProperties();
System.setProperty("https.proxyHost", "a-proxyserver");
System.setProperty("https.proxyPort", "80");
System.setProperty("https.proxyUserName", "a-username");
System.setProperty("https.proxyPassword", "a-passwd");
System.setProperty("https.proxySet", "true");
System.setProperty("http.proxyHost", "proxy_server");
System.setProperty("http.proxyPort", "80");
System.setProperty("http.proxyUserName", "a-username");
System.setProperty("http.proxyPassword", "a-passwd");
System.setProperty("http.proxySet", "true");
//System.setProperties(props);
URLEndpoint dest =
new URLEndpoint("http://api.google.com/search/beta2");
javax.xml.soap.SOAPMessage reply = conn.call(message, dest);
TransformerFactory tFact = TransformerFactory.newInstance();
Transformer t = tFact.newTransformer();
Source srcContent = reply.getSOAPPart().getContent();
StreamResult res = new StreamResult("doGoogleSearchresp.xml");
t.transform(srcContent, res);
System.out.println("Received reply from: " + m_hostURL);
//Display reply from endpoint
boolean dispRes = true;
if(dispRes)
//Dump onto screen
System.out.println("Result:");
reply.writeTo(System.out);
conn.close();
}catch(Throwable e){
e.printStackTrace();
public static void main(String args[])
//String hostURL = DEFAULT_HOST_NAME;
Properties sysprop= System.getProperties();
//sysprop.put("firewallHost", "proxy_server");
//sysprop.put("firewallPort", "80");
//sysprop.put("firewallSet", "true");
//sysprop.put("proxyHost", "proxy_server");
//sysprop.put("proxyPort", "80");
//sysprop.put("proxySet", "true");
try
GoogleJPClient gjc = new GoogleJPClient("http://api.google.com/search/beta2");
gjc.sendGoogJMsg();
}catch(Exception e){
e.printStackTrace();
========================================================================
As you can see it's pretty messy, and I've tried getting around the HTTPS proxy in a variety of methods, but with no results.
Please help.
Rgds,
frustrated.Hi,
I've just experienced trouble with the same thing and I found that setting the following System properties works fine when I use the Apache Axis 1.0 libraries. Note that it's "proxyUser" and not "proxyUserName".
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "10.1.1.1");
System.setProperty("http.proxyPort", "80");
System.setProperty("http.proxyUser", "mydomain\\myusername");
System.setProperty("http.proxyPassword", "mypassword");
I can then make HTTP and HTTPS connections and send SOAP messages with no worries.
I'm in an NT environment and hence had to specify the domain as well as the username (and escape the backslash between them) for the proxy to let me through otherwise I got a "407 proxy authentication required" error.
I'm certain this works fine as I've tested it myself.
Hope this helps you out.
Shane. -
Please help with jsp and database!!
Hello,
i first created a jsp page and printed out the parameters of a user's username when they logged in. example, "Welcome user" and it worked fine...
i inserted a database into my site that validates the username and password, and ever since i did that in dreamweaver, when a user logs in sucessfully, it returns the jsp page like its supposed to, only that it says "Welcome null" instead of "Welcome John." pretty strange, huh!? can anyone please help? thanks!
here is the important part of the code to Login.jsp, and LoginSuccess.jsp: <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<%@ include file="Connections/Login.jsp" %>
<%
// *** Validate request to log in to this site.
String MM_LoginAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) MM_LoginAction += "?" + request.getQueryString();
String MM_valUsername=request.getParameter("Username");
if (MM_valUsername != null) {
String MM_fldUserAuthorization="";
String MM_redirectLoginSuccess="LoginSuccess.jsp";
String MM_redirectLoginFailed="LoginFailure.jsp";
String MM_redirectLogin=MM_redirectLoginFailed;
Driver MM_driverUser = (Driver)Class.forName(MM_Login_DRIVER).newInstance();
Connection MM_connUser = DriverManager.getConnection(MM_Login_STRING,MM_Login_USERNAME,MM_Login_PASSWORD);
String MM_pSQL = "SELECT UserName, Password";
if (!MM_fldUserAuthorization.equals("")) MM_pSQL += "," + MM_fldUserAuthorization;
MM_pSQL += " FROM MemberInformation WHERE UserName=\'" + MM_valUsername.replace('\'', ' ') + "\' AND Password=\'" + request.getParameter("Password").toString().replace('\'', ' ') + "\'";
PreparedStatement MM_statementUser = MM_connUser.prepareStatement(MM_pSQL);
ResultSet MM_rsUser = MM_statementUser.executeQuery();
boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
if (MM_rsUser_isNotEmpty) {
// username and password match - this is a valid user
session.putValue("MM_Username", MM_valUsername);
if (!MM_fldUserAuthorization.equals("")) {
session.putValue("MM_UserAuthorization", MM_rsUser.getString(MM_fldUserAuthorization).trim());
} else {
session.putValue("MM_UserAuthorization", "");
if ((request.getParameter("accessdenied") != null) && false) {
MM_redirectLoginSuccess = request.getParameter("accessdenied");
MM_redirectLogin=MM_redirectLoginSuccess;
MM_rsUser.close();
MM_connUser.close();
response.sendRedirect(response.encodeRedirectURL(MM_redirectLogin));
return;
%>
<form action="<%=MM_LoginAction%>" method="get" name="Login" id="Login">
<table width="55%" border="0">
<tr>
<td width="41%">Username </td>
<td width="59%"><input name="Username" type="text" id="Username" value="" size="25" maxlength="10"></td>
</tr>
<tr>
<td>Password </td>
<td><input name="Password" type="password" id="Password" value="" size="25" maxlength="10"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>And LoginSuccess.jsp where i want it to print out the "Welcome username
<%String Name=request.getParameter("Username");
out.println ("Welcome ");
out.println (Name); %><%@ page contentType="text/html; charset=iso-8859-1"
language="java" import="java.sql.*" %>
<%@ include file="Connections/Login.jsp" %>
<%
// *** Validate request to log in to this site.
String MM_LoginAction = request.getRequestURI();
if (request.getQueryString() != null &&
request.getQueryString().length() > 0) MM_LoginAction
+= "?" + request.getQueryString();
String
MM_valUsername=request.getParameter("Username");
if (MM_valUsername != null) {
String MM_fldUserAuthorization="";
String MM_redirectLoginSuccess="LoginSuccess.jsp";
String MM_redirectLoginFailed="LoginFailure.jsp";
String MM_redirectLogin=MM_redirectLoginFailed;
Driver MM_driverUser =
=
(Driver)Class.forName(MM_Login_DRIVER).newInstance();
Connection MM_connUser =
=
DriverManager.getConnection(MM_Login_STRING,MM_Login_US
RNAME,MM_Login_PASSWORD);
String MM_pSQL = "SELECT UserName, Password";
if (!MM_fldUserAuthorization.equals("")) MM_pSQL +=
= "," + MM_fldUserAuthorization;
MM_pSQL += " FROM MemberInformation WHERE
E UserName=\'" + MM_valUsername.replace('\'', ' ') +
"\' AND Password=\'" +
request.getParameter("Password").toString().replace('\'
, ' ') + "\'";
PreparedStatement MM_statementUser =
= MM_connUser.prepareStatement(MM_pSQL);
ResultSet MM_rsUser =
= MM_statementUser.executeQuery();
boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
if (MM_rsUser_isNotEmpty) {
// username and password match - this is a valid
lid user
session.putValue("MM_Username", MM_valUsername);
if (!MM_fldUserAuthorization.equals("")) {
session.putValue("MM_UserAuthorization",
ion",
MM_rsUser.getString(MM_fldUserAuthorization).trim());
} else {
session.putValue("MM_UserAuthorization", "");
if ((request.getParameter("accessdenied") != null)
ll) && false) {
MM_redirectLoginSuccess =
ess = request.getParameter("accessdenied");
MM_redirectLogin=MM_redirectLoginSuccess;
MM_rsUser.close();
MM_connUser.close();
response.sendRedirect(response.encodeRedirectURL(MM_re
irectLogin));
return;
%>
<form action="<%=MM_LoginAction%>" method="get"
"get" name="Login" id="Login">
<table width="55%" border="0">
<tr>
<td width="41%">Username </td>
<td width="59%"><input name="Username"
="Username" type="text" id="Username" value=""
size="25" maxlength="10"></td>
</tr>
<tr>
<td>Password </td>
<td><input name="Password" type="password"
="password" id="Password" value="" size="25"
maxlength="10"></td>
</tr>
<tr>
<td>�</td>
<td><input type="submit" name="Submit"
me="Submit" value="Submit"></td>
</tr>
</table>
</form>
And LoginSuccess.jsp where i want it to print out the
"Welcome username
<%String Name=request.getParameter("Username");
out.println ("Welcome ");
out.println (Name); %>When the page is rediredted u r not passing the user name in the query string,so it is not availble in the query string for LoginSuccess page
Since u have added user in session user this
<%String Name=(String)session.getValue("MM_Username") ;%>
<% out.println ("Welcome ");
<% out.println (Name); %> -
Please help me to complete this code
import java.security.MessageDigest;
import java.util.Map;
import java.util.Scanner;
public class PasswordService
//The hash is to be formed using the SHA algorithm
//to create a MessageDigest
private final String algorithmName = "SHA";
//Use a message digest to create hashed passwords
private MessageDigest md = null;
//We simulate a database of users using who have a login and password
//as a key and value pair in a Map
private Map<String, byte[]> userData;
//complete the constructor
public PasswordService()
//TODO - intialize the class instance data
//some dummy data - do not alter these lines
addUser("daddy", "cool");
addUser("nightflight", "topChat");
addUser("boney", "2E5sxuSRg6A");
public void showProvider()
//TODO
//Get the hash value for the provided string password.
public byte[] getHash(String password)
//TODO
return null;
public void addUser(String login, String password)
//TODO
public byte[] getPassword(String login)
//TODO
return null;
public boolean checkLogin(String login, String password)
// TODO
return false;
//This method is provided to perform a login from the command line
public boolean doLogin()
Scanner sc = new Scanner(System.in);
System.out.println("Enter login please");
String login = sc.next();
System.out.println("Your password please");
String password = sc.next();
return checkLogin(login, password);
public static void main(String[] args)
int attempts = 0;
showProvider();
while(attempts < 4)
boolean match = doLogin(); //request login and password
System.out.println("match? " + match);
attempts++;
}please help me to complete this code
void completeCode(Code code,Properties options) throws CodeCompletingException
CodeCompleterFactory cf = CodeCompleterFactory.newInstance();
CodeCompleter cc = cf.newCodeCompleter();
cc.complete(code,options);
} -
XML deserialize and decrypting encoding problem. Please help me
This is my first topic here, so at first I'd like to say "Hi" everyone and apologise for my bad english ;)
I have just finished my new application about signing/checking and encrypting/decrypting XML files. I use Apache XML Security packages to do this.
Everything works fine, instead of one...
I'm Polish and sometimes I have to encrypt or decrypt XML which includes polish letters like: 'ą' , 'ę', 'ł' and some others... If I encrypt such file, it succeeds. The problem is when I try to decrypt such an encrypted file. I recieve an error like :
"[Fatal Error] :2:7: An invalid XML character (Unicode: 0x19) was found in the element content o
f the document.
gov.mf.common.exceptions.SenderException: E_SENDER_DECRYPTION
at gov.mf.common.xml.encryption.EncryptTool.decrypt(Unknown Source)
at gov.mf.CERBER.TestCBR.main(Unknown Source)
Caused by: org.apache.xml.security.encryption.XMLEncryptionException: An invalid XML character
(Unicode: 0x19) was found in the element content of the document.
Original Exception was org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x19)
was found in the element content of the document.
at org.apache.xml.security.encryption.XMLCipher$Serializer.deserialize(Unknown Source)
at org.apache.xml.security.encryption.XMLCipher.decryptElement(Unknown Source)
at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
... 2 more
What's wrong? My XML document is UTF-8 encoded, with or without BOM. I wrote in in Notepad++ or any other editior which has UTF-8 encoding.
I'm parsing my XML with DOM. There is an interesting line in an error above like: " at org.apache.xml.security.encryption.XMLCipher$Serializer.deserialize(Unknown Source)" , do you know that?
Everything is fine when I try to encrypt/decrypt '�' or 'ń', but things go wrong with 'ą', 'ę', 'ł' and others... I also managed to encrypt and decrypt 'ł' but unfortunately, after decryption 'ł' turns into 'B'. It obviously an encoding problem, but how to fix it?
I would be really thankfull if some of You guys would help me.
Looking forward fo any answers.
Matthew
Message was edited by:
matthew_plHi once again.
I still don't havy any solution to my problem. I used Apache XML Security examples to encrypt/decrypt my XML document with Polish charaters but I also recieve the same error. What's wrong?
Here is some code:
----- Parsing XML do Document ------
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//Bardzo wazna linijka - bless TEK ;)
factory.setNamespaceAware(true);
DocumentBuilder builder;
builder = factory.newDocumentBuilder();
File f = new File(Const.FILE_IN_PATH + File.separator + Const.FILE_IN);
org.w3c.dom.Document doc = builder.parse(f);
---------- Encrypting & Decrypting XML document (whole class) -------------
import java.io.*;
import java.security.*;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.utils.EncryptionConstants;
import org.apache.xml.security.encryption.XMLCipher;
import org.apache.xml.security.encryption.EncryptedData;
import org.apache.xml.security.encryption.EncryptedKey;
public class EncryptTool
private PublicKey publicKey;
private PrivateKey privateKey;
static
org.apache.xml.security.Init.init();
public EncryptTool()
publicKey = KeyStores.getCerberPublicKey();
privateKey = KeyStores.getCerberPrivateKey();
public Document encrypt(Document doc, String sufix)
try
byte[] passPhrase = "24 Bytes per DESede key!".getBytes("UTF-8");
DESedeKeySpec keySpec = new DESedeKeySpec(passPhrase);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");
SecretKey secretKey = keyFactory.generateSecret(keySpec);
XMLCipher keyCipher = XMLCipher.getInstance(XMLCipher.RSA_v1dot5);
keyCipher.init(XMLCipher.WRAP_MODE, publicKey);
EncryptedKey encryptedKey = keyCipher.encryptKey(doc, secretKey);
Element elementToEncrypt = (Element) doc.getDocumentElement();
System.out.println("Szyrfuję: " + elementToEncrypt.getTextContent());
XMLCipher xmlCipher = XMLCipher.getInstance(XMLCipher.TRIPLEDES);
xmlCipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
EncryptedData encryptedDataElement = xmlCipher.getEncryptedData();
KeyInfo keyInfo = new KeyInfo(doc);
keyInfo.add(encryptedKey);
encryptedDataElement.setKeyInfo(keyInfo);
boolean encryptContentsOnly = true;
xmlCipher.doFinal(doc, elementToEncrypt, encryptContentsOnly);
// output the resulting document
String [] parts = Const.FILE_IN.split("\\.");
String saveAs = Const.FILE_OUT_PATH + File.separator + parts[0] + sufix + "." + parts[1];
OutputStream os = new FileOutputStream(saveAs);
XMLUtil.sameXMLtoFile(doc, os);
} catch (Exception ex)
throw new TestCBRException("E_CERBER_ENCRYPTION", ex);
return doc;
public void decrypt(Document doc, String sufix) throws SenderException
try
String namespaceURI = EncryptionConstants.EncryptionSpecNS;
String localName = EncryptionConstants._TAG_ENCRYPTEDDATA;
int ile = doc.getElementsByTagNameNS(namespaceURI, localName).getLength();
if (ile == 0) throw new SenderException("E_SENDER_DECRYPTION_NEEDED");
for(int i=0; i < ile; i++)
Element encryptedDataElement = (Element) doc.getElementsByTagNameNS(namespaceURI, localName).item(0);
XMLCipher xmlCipher = XMLCipher.getInstance();
xmlCipher.init(XMLCipher.DECRYPT_MODE, null);
xmlCipher.setKEK(privateKey);
xmlCipher.doFinal(doc, encryptedDataElement);
String [] parts = Const.FILE_IN.split("\\.");
String saveAs = Const.FILE_OUT_PATH + parts[0] + sufix + "." + parts[1];
OutputStream os = new FileOutputStream(saveAs);
XMLUtil.saveXMLtoFile(doc, os);
} catch (SenderException ex) {
throw ex;
} catch (Exception ex) {
throw new SenderException("E_SENDER_DECRYPTION", ex);
Please help me. I'm going into madness what's wrong with it... -
Please help regarding method/function sign up validation with mysql jdbc.
HI guys,
I am have been fixing this problem for days, hope that someone could help me find the bug on my code.
I have 3 files:
1.WithAuth.java - for database jdbc mysql connection
2.WithAuthMet.java - method that will read any variables that will be passed to it. this method is waiting for two variables, a and b. a for userName and b for userPassword.
3.WithAuthTest.java - the testing class, this is where i declare my sample control data to test the database connection and query.
here's the actual codes:
WithAuth.java
package com.Auth;
public class WithAuth {
static String userName = "root";
static String userPassword = "";
static String databaseUrl = "jdbc:mysql://localhost:3306/javatowebservice";
static String userQuery = "select * from userlogin";
}WithAuthMet.java
- this is where the error is and where I messed up.
package com.Auth;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class WithAuthMet extends WithAuth {
public void connect(String a, String b)throws Exception{
//try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection (databaseUrl, userName, userPassword);
Statement stat = conn.createStatement();
String query = userQuery;
ResultSet result = stat.executeQuery(query);
System.out.println("Result(s): ");
while (result.next ()){
int i = result.getInt("userId");
String name=result.getString("userName");
String password=result.getString("userPassword");
//System.out.println("test data:"+a);
if(a.equals(name.equals("userName"))&& b.equals(password.equals("userPassword"))){
System.out.println("User is Valid");
else{
System.out.println("You are not a Valid User");
System.out.println("test data:"+name);
System.out.println("test data:"+password);
System.out.println("test data:"+a);
System.out.println("test data:"+b);
//conn.close();
// }catch(Exception e){
//System.out.println("Exception is ;"+e);
//System.out.println("Exception is ;");
// if(a.equals(name.("userName"))
// && password.equals(password.equals("userPassword"))){
// System.out.println("User is Valid");
// else{
// System.out.println("You are not a Valid User");
} WithAuthTest.java
package com.Auth;
public class WithAuthTest extends WithAuthMet{
public static void main(String[] args) throws Exception{
WithAuthMet CTD = new WithAuthMet();
String a = "dan";
String b = "password";
//CTD.connect(String name,String password);
CTD.connect(a, b);
//return connect;
}please help.yakultyakultyakult wrote:
WithAuthMet.java
- this is where the error is and where I messed up.
package com.Auth;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class WithAuthMet extends WithAuth {
public void connect(String a, String b)throws Exception{
//try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection (databaseUrl, userName, userPassword);
Statement stat = conn.createStatement();
String query = userQuery;
ResultSet result = stat.executeQuery(query);
System.out.println("Result(s): ");
while (result.next ()){
int i = result.getInt("userId");
String name=result.getString("userName");
String password=result.getString("userPassword");
//System.out.println("test data:"+a);
if(a.equals(name.equals("userName"))&& b.equals(password.equals("userPassword"))){
System.out.println("User is Valid");
else{
System.out.println("You are not a Valid User");
System.out.println("test data:"+name);
System.out.println("test data:"+password);
System.out.println("test data:"+a);
System.out.println("test data:"+b);
//conn.close();
// }catch(Exception e){
//System.out.println("Exception is ;"+e);
//System.out.println("Exception is ;");
// if(a.equals(name.("userName"))
// && password.equals(password.equals("userPassword"))){
// System.out.println("User is Valid");
// else{
// System.out.println("You are not a Valid User");
This is one line that is wrong
if(a.equals(name.equals("userName"))&& b.equals(password.equals("userPassword"))){You have 'a' and 'b which are Strings
and you are comparing them [using equals()] with the boolean return from another set of equals() invocations.
String equals boolean will always be false (well, maybe not if the String is "TRUE" or "FALSE" - and you would need some more boilerplate to make that work).
Maybe you are looking for
-
[nForce] Drivers Won't Install
I have a K7N2 Delta2 motherboard. It has a NVIDIA nForce2 Ultra 400 chipset. I am trying to install the drivers for these integrated components: NVIDIA nForce2 AGP Host to PCI Bridge NVIDIA nForce2 Memory Controller NVIDIA nForce2 Ultra 400 Memory
-
F110 - Clearing Date for Documents
We Run the F110 on 28.07.2011 and it is run with successfully for payments. But actually we run it on 28.07.2011 Date but it will take for the clearing documents 29.07.2011. I don't know how it will take for clearing documents with 29.07.2011? Can yo
-
Wrong values in the cube S001.
good morning people, we are with the ecc 6.0 installed almost 01 years, the analysis made in the reports that use the standard cube S001, are with with wrong values. This problem does not happen with all materials in a given month, it appears as if t
-
Brand New iPod- Brand New Account- Could Not Sign In An Unknown Error Has Occurred
Just got home with a brand new iPod touch from the Apple Store. iOs 6.0.1 Set up a brand new Apple ID and iCloud account. Verfied and confirmed the account via email on the iPod. iPod has not been attached to a computer. I am attempting to download
-
Importing archived mailbox?
I archived two mailboxes from Apple Mail and now I can't access them. I can see them as a single conjoined mbox file in Finder. But when I try to import this file back into Apple Mail, I can click on the import folder that gets created and that opens