Problem in debug a servlet
hello all,
i am using eclipse 3.2 and tomcat 5.0.28
i made a servlet class ServletFetchingDataFromDatabase.java in this package ( given below )
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ServletDataBaseConnection\src\servlet
and corresponding this java file .... its class file situated in this package ( given below )
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ServletDataBaseConnection\build\classes\servlet
because of my java file in servlet package , i wrote this file ( given below )
package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletFetchingDataFromDatabase extends HttpServlet {
private static final long serialVersionUID = 8572240412874905464L;
String url = "jdbc:mysql://localhost/mokshadatabase";
String user = "root";
String password = "password";
String jdbcDriver = "com.mysql.jdbc.Driver";
public void doGet(HttpServletRequest request , HttpServletResponse response) throws ServletException , IOException{
String query = null;
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<body>");
pw.println("<form>");
pw.println("Servlet DataBase Connection<br>");
pw.println("Patient Master Table <br><br>");
try{
Class.forName(jdbcDriver).newInstance();
Connection conn = DriverManager.getConnection(url, user, password);
query = "SELECT * FROM mhis_m_patientmaster";
PreparedStatement stmt = conn.prepareStatement(query);
stmt.executeQuery();
ResultSet rs = stmt.getResultSet();
pw.println("<table border = 1>");
pw.println("<tr>");
pw.println("<td>patient_Id</td>");
pw.println("<td>patient_Registration_Date</td>");
pw.println("<td>patient_Registration_Time</td>");
pw.println("<td>patient_First_Name</td>");
pw.println("<td>patient_Last_Name</td>");
pw.println("</tr>");
while(rs.next()){
pw.println("<tr>");
if("".equalsIgnoreCase(rs.getString(1))){
pw.println("<td>Null</td>");
}else{
pw.println("<td>" + rs.getString(1) + "</td>");
if("".equalsIgnoreCase(rs.getString(2))){
pw.println("<td>Null</td>");
}else{
pw.println("<td>" + rs.getString(2) + "</td>");
pw.println("</tr>");
pw.println("</table>");
}catch(IllegalAccessException e){
pw.println("Error is : " + e.getMessage() + "<br>");
pw.println("Error is IllegalAccessException<br>");
}catch (ClassNotFoundException e) {
pw.println("Error is : " + e.getMessage() + "<br>");
pw.println("Error is ClassNotFoundException<br>");
}catch(InstantiationException e){
pw.println("Error is : " + e.getMessage() + "<br>");
pw.println("Error is InstantiationException<br>");
}catch(SQLException e){
pw.println("Error is : " + e.getMessage() + "<br>");
pw.println("Error is SQLException<br>");
pw.println("</form>");
pw.println("</body>");
pw.println("</html>");
}and web.xml .. i wrote
<!-- ServletFetchingDataFromDatabase.java (In side servlet package ) -->
<servlet>
<servlet-name>servlet\ServletFetchingDataFromDatabase</servlet-name>
<servlet-class>servlet.ServletFetchingDataFromDatabase</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet\ServletFetchingDataFromDatabase</servlet-name>
<url-pattern>/servlet/ServletFetchingDataFromDatabase.do</url-pattern>
</servlet-mapping>now when i debug it then it gives error like that...
HTTP Status 404 - /ServletDataBaseConnection/servlet/servlet.ServletFetchingDataFromDatabase.do
type Status report
message /ServletDataBaseConnection/servlet/servlet.ServletFetchingDataFromDatabase.do
description The requested resource (/ServletDataBaseConnection/servlet/servlet.ServletFetchingDataFromDatabase.do) is not available.main thing is that when i check it from web browser
( http://localhost:8080/ServletDataBaseConnection/servlet/ServletFetchingDataFromDatabase.do ) then it gives correct out put .. no problem is there..but when i check it by debug using break point ...then it gives this error....
i thing this problem is related to web.xml ... but if this web.xml is wrong then why this web.xml gives write out put from when i checked it by browser...
Hi ,
I really dont understand why you are making such a complicated folder structure for servlet.
May be i m wrong, but if you are using eclipse everything is straight forward.
Just create dynamic web project create servlet into src & jsp into webcontent . Everything place in your
workspace thats all. Just simply call your servlet thats it
Please Revert Back
Sachin Kokcha
Similar Messages
-
Problem with debug servlet Eclipse 3 tomcat 5
I have configured Eclipse 3 with Tomcat 5.0.28 and tomcatPulginV3
but, I have problem to debug my servlet
I have error message
help me it is urgent
Failed to connect to remote VM. Connection refused.
java.net.ConnectException: Connection refused: connect
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.PlainSocketImpl.doConnect(Unknown Source)
java.net.PlainSocketImpl.connectToAddress(Unknown Source)
java.net.PlainSocketImpl.connect(Unknown Source)
java.net.Socket.connect(Unknown Source)
java.net.Socket.connect(Unknown Source)
java.net.Socket.<init>(Unknown Source)
java.net.Socket.<init>(Unknown Source)
org.eclipse.jdi.internal.connect.SocketTransportImpl.attach(SocketTransportImpl.java:47)
org.eclipse.jdi.internal.connect.SocketAttachingConnectorImpl.attach(SocketAttachingConnectorImpl.java:103)
org.eclipse.jdt.internal.launching.SocketAttachConnector.connect(SocketAttachConnector.java:131)
org.eclipse.jdt.internal.launching.JavaRemoteApplicationLaunchConfigurationDelegate.launch(JavaRemoteApplicationLaunchConfigurationDelegate.java:75)
org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:569)
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:788)
org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlugin.java:955)
org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)ThanksCheck your packages which you are importing....
-
Casting problems getting a home I/F of an EJB in another app when debuging a servlet
(Jdeveloper version = 9.0.2.798, OC4J Application Server version = Oracle9iAS (9.0.2.0.0))
I am trying to debug a multi-tier application using the embedded application server. Servlets and EJBs within that application need to call EJBs contained within a second application (Horus).
I have set up the embedded application server to run this second application automatically by adding the following entry into its server.xml
<application auto-start="true" name="Horus" path="M:\Studio\build\production\java\Server\Obfuscate\J2EE_HOME\Horus\Horus.xml"/>
I then start the embedded application server by debugging my servlet project, 'intermediateServlet'. I know the second application is running correctly in the embedded application server because I can access it from a separate client.
In the 'intermediateServlet', I want to obtain a reference to a Dispatcher EJB held in the Horus application. This EJB has the following properties
ejb-name = com.internal.server.Dispatcher
home interface = com.internal.server.DispatcherHome
bean class = com.internal.server.DispatcherEJB
remote interface= com.internal.server.Dispatcher
The following code is executed during the container's call to my servlet init( context ) method to try and get the appropriate home interface.
Context context = null;
Object tempRemoteIF1 = null;
Object tempRemoteIF2 = null;
Properties h = null;
h = new Properties();
h.put( Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory" );
h.put( Context.PROVIDER_URL, "ormi://127.0.0.1:23891/Horus");
h.put( Context.SECURITY_PRINCIPAL, "user0" );
h.put( Context.SECURITY_CREDENTIALS, "password" );
context = new InitialContext (h);
tempRemoteIF1 = context.lookup( "com.internal.server.Dispatcher" );
tempRemoteIF2 = javax.rmi.PortableRemoteObject.narrow
tempRemoteIF1,
Class.forName( "com.internal.server.DispatcherHome" )
The context.lookup call seems to work fine, returning an object of the class
DispatcherHome_StatelessSessionHomeWrapper5
Which I presume is a containter generated class implementing the home interface. To help confirm this,
the object has a property beanName that has the value "com.internal.server.Dispatcher".
The problem occurs on the next line, when I check whether I can cast the object to the home interface using ProtableRemoteObject.narrow(). This gives the following exception.
java.lang.ClassCastException
java.lang.Object com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:296
java.lang.Object javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:137
com.internal.server.Dispatcher com.Studio.servlet.intermediateServlet.getDispatcherRef(java.lang.String, java.lang.String, java.lang.String)
intermediateServlet.java:601
void com.Studio.servlet.intermediateServlet.init(javax.servlet.ServletConfig)
intermediateServlet.java:150
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.loadServlet(com.evermind.util.ByteString)
HttpApplication.java:1669
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.findServlet(com.evermind.util.ByteString)
HttpApplication.java:4001
javax.servlet.RequestDispatcher com.evermind.server.http.HttpApplication.getRequestDispatcher(com.evermind.util.ByteString, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse)
HttpApplication.java:2200
boolean com.evermind.server.http.HttpRequestHandler.processRequest(com.evermind.server.ApplicationServerThread, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
HttpRequestHandler.java:580
void com.evermind.server.http.HttpRequestHandler.run(java.lang.Thread)
HttpRequestHandler.java:243
void com.evermind.util.ThreadPoolThread.run()
ThreadPoolThread.java:62
Interestingly, if I use practically the same code, to obtain the home interface of an EJB that is defined in the application that I am debugging, the cast works perfectly. The returned object looks identical, apart from the name to the DispatcherHome_StatelessSessionHomeWrapper5 mentioned above.
Could the error possibly be because I need to declare 'Horus' as a parent application of the application I am debugging? If it is how do I do this?
Many thanks in advance for any help with this one.
Mark.(Jdeveloper version = 9.0.2.798, OC4J Application Server version = Oracle9iAS (9.0.2.0.0))
I am trying to debug a multi-tier application using the embedded application server. Servlets and EJBs within that application need to call EJBs contained within a second application (Horus).
I have set up the embedded application server to run this second application automatically by adding the following entry into its server.xml
<application auto-start="true" name="Horus" path="M:\Studio\build\production\java\Server\Obfuscate\J2EE_HOME\Horus\Horus.xml"/>
I then start the embedded application server by debugging my servlet project, 'intermediateServlet'. I know the second application is running correctly in the embedded application server because I can access it from a separate client.
In the 'intermediateServlet', I want to obtain a reference to a Dispatcher EJB held in the Horus application. This EJB has the following properties
ejb-name = com.internal.server.Dispatcher
home interface = com.internal.server.DispatcherHome
bean class = com.internal.server.DispatcherEJB
remote interface= com.internal.server.Dispatcher
The following code is executed during the container's call to my servlet init( context ) method to try and get the appropriate home interface.
Context context = null;
Object tempRemoteIF1 = null;
Object tempRemoteIF2 = null;
Properties h = null;
h = new Properties();
h.put( Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory" );
h.put( Context.PROVIDER_URL, "ormi://127.0.0.1:23891/Horus");
h.put( Context.SECURITY_PRINCIPAL, "user0" );
h.put( Context.SECURITY_CREDENTIALS, "password" );
context = new InitialContext (h);
tempRemoteIF1 = context.lookup( "com.internal.server.Dispatcher" );
tempRemoteIF2 = javax.rmi.PortableRemoteObject.narrow
tempRemoteIF1,
Class.forName( "com.internal.server.DispatcherHome" )
The context.lookup call seems to work fine, returning an object of the class
DispatcherHome_StatelessSessionHomeWrapper5
Which I presume is a containter generated class implementing the home interface. To help confirm this,
the object has a property beanName that has the value "com.internal.server.Dispatcher".
The problem occurs on the next line, when I check whether I can cast the object to the home interface using ProtableRemoteObject.narrow(). This gives the following exception.
java.lang.ClassCastException
java.lang.Object com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:296
java.lang.Object javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:137
com.internal.server.Dispatcher com.Studio.servlet.intermediateServlet.getDispatcherRef(java.lang.String, java.lang.String, java.lang.String)
intermediateServlet.java:601
void com.Studio.servlet.intermediateServlet.init(javax.servlet.ServletConfig)
intermediateServlet.java:150
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.loadServlet(com.evermind.util.ByteString)
HttpApplication.java:1669
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.findServlet(com.evermind.util.ByteString)
HttpApplication.java:4001
javax.servlet.RequestDispatcher com.evermind.server.http.HttpApplication.getRequestDispatcher(com.evermind.util.ByteString, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse)
HttpApplication.java:2200
boolean com.evermind.server.http.HttpRequestHandler.processRequest(com.evermind.server.ApplicationServerThread, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
HttpRequestHandler.java:580
void com.evermind.server.http.HttpRequestHandler.run(java.lang.Thread)
HttpRequestHandler.java:243
void com.evermind.util.ThreadPoolThread.run()
ThreadPoolThread.java:62
Interestingly, if I use practically the same code, to obtain the home interface of an EJB that is defined in the application that I am debugging, the cast works perfectly. The returned object looks identical, apart from the name to the DispatcherHome_StatelessSessionHomeWrapper5 mentioned above.
Could the error possibly be because I need to declare 'Horus' as a parent application of the application I am debugging? If it is how do I do this?
Many thanks in advance for any help with this one.
Mark. Try loading the home interface from the same classloader used to load the the returned home object.
tempRemoteIF2 = javax.rmi.PortableRemoteObject.narrow
( tempRemoteIF1,
tempRemoteIF1.getClass().getClassLoader().loadClass("com.internal.server.DispatcherHome" )
Dhiraj -
Problem with Sessions in Servlets
Hi,
I'm having a problem with sesions with servlets. It seems that if someone logs into my website, which is running on all servlets, while another person is logged on, the second person gets the session of the first person.
I'm using
HttpSession session = request.getSession(true);to get the session in each page. The session contains a user object which shows if the user is logged in and what permissions.
The session should be unique to the client computer right? Or am I jsut screwing this up big time?Yes, each client will have their own session. However, you may be testing incorrectly:
In Firefox, for example, all instances of the application running on the same machine will share the same cookies, therefore the same session, and would be considered one client.
MS IE will do the same if you use File - New to open a new wondow rather than clicking on the desktop icon.
If the different clients are using different machines and still getting shared data, then you may be using class-level variables in the servlet, which would not be thread safe and could lead to your problems...
public class MyServlet extends HttpServlet {
String data; //bad
int moredata; //bad
public void doGet(...) ... { ... }
} -
Problem with logout in servlet After logging out i need to expire the pages
I have a problem in logout using servlet.
I introduced sessions in my page and while logout i used
session.removeAttribute("name");
session.removeAttribute("password");
res.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
res.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
res.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
String user=(String)session.getAttribute("name");
System.out.println(user);
if(user==null)
System.out.println("hi");
req.setAttribute("Error", "Session has ended. Please login.");
res.sendRedirect("http://localhost:8080/homepage.html");
and after i logout im redirected to login page but after clicking back button im getting back to restricted pages(the pages b4 logout).
what should i do?????Thanks Dear BalusC,
I tried with this,
rs.getString("DATA_SCAD1")// where the source from .xls files
String pattern = "yyyy-MM-dd";
SimpleDateFormat format = new SimpleDateFormat(pattern);
try {
Date date = format.parse("DATA_SCAD1");
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
System.out.println(format.format(new Date()));
this out put gives me Tue Apr 03 00:00:00 IST 2007
But I want to display the date format in yyyy-mm-dd.
regards,
maza -
Facing Problem while Debugging a custom report using LDB
Hi Gurus,
I have requirement to modify a custom report program related to FI. This program used Logical database ZDF ( Copied original DDF) for data fetching.
when i am trying to see the data in debugging mode, its not allowing to check in start-of-selection event. only in the initialization & end-of-selection i could able to debug.
when i put breakpoint in initialization, it is allowing to see the flow till a Get Event occurs in the code, once a Get event occur the debugger is coming out and displaying the report.
If anybody faced this kind of problem when debugging a report using LDB, please share how you resolved it. If there are any other ways to debug a program of this kind please help me.
Thanks,
NandaHi Amith,
I checked that way also, i put break point in database program of the copied LDB, but its not allowing to check the flow in that program also.
Please suggest any other ways.
Thanks,
Nanda -
Is my understanding correct you cannot debug a servlet in weblogic8.1 - or am I
suffering from finger trouble?
I have a servlet with breakpoints that are never actioned - even though I know
I executing the code, I can edit, build and change its behaviour - but the breakpoints
are ignored!
If a project contains a runnable object like a xxx.jws file the debugger launches
as expected.
JohnYou might try connecting to your running server with a standard JPDA debugger like
NetBeans or Eclipse, with a project pointing to your source code. That works
fine for me. I'm assuming by implication that you're trying to use WebLogic Workshop
to do this.
"john" <[email protected]> wrote:
>
Is my understanding correct you cannot debug a servlet in weblogic8.1
- or am I
suffering from finger trouble?
I have a servlet with breakpoints that are never actioned - even though
I know
I executing the code, I can edit, build and change its behaviour - but
the breakpoints
are ignored!
If a project contains a runnable object like a xxx.jws file the debugger
launches
as expected.
John -
Hello
I have problem with debug program for XT75. I work in XP , install java j2sdk1.4.2_09 (from CD) , eclipse (with EclipseMEplugin_123) ,SMTK and connect terminal TC65 with XT75 module.
When I want to debug my simple Midlet HelloWorld under celipse I get error:
=========================================================================
Starting XT75 emulator for debugging application. Please wait ...
=========================================================================
COM port used for "emulator session": COM1
Used baud rate for the module "115200 baud"..
>>> Emulator is set to no download of Jar and Jad file! <<<
Initialize module for debugging ...
The module is now initialized for debugging!
>>> Establishing TCP/IP connection "IP connection for remote debugging"... <<<
Please wait ...
Done.
>>> Starting Debug Agent ... <<<
The debug agent is not started!
File WM_Debug_config.ini in WTK for XT75 is:
# This ini file is used to configure emulator.exe
# Hints:
# Store this ini file into the directory where the emulator.exe is located!
[Module type]
# Define the used module type
ModuleType=XT75
[AT command]
# These AT commands are used for initialising the module for debugging!
# Hints:
# The IP address range 10.x.x.x is not supported for configuration of debugging!
AT-Cmd1=S:ATE1
AT-Cmd2=R:OK
AT-Cmd3=S:at+cpin?
AT-Cmd4=R:+CPIN: READY
AT-Cmd5=R:OK
AT-Cmd6=S:at^scfg=userware/debuginterface,"192.168.0.21","192.168.0.22","0"
AT-CMd7=R:^SCFG: "Userware/DebugInterface","192.168.0.21","192.168.0.22","0"
AT-Cmd8=R:OK
AT-Cmd9=S:at^scfg=userware/mode,"debug","a:/","2000"
AT-Cmd10=R:^SCFG: "Userware/Mode","debug","a:/","2000"
AT-Cmd11=R:OK
AT-Cmd12=S:at^scfg=userware/stdout,UDP,2000
AT-Cmd13=R:^SCFG: "Userware/Stdout","UDP","2000"
AT-Cmd14=R:OK
[System.out port]
# used UDP port number range: 1024 ... 65535
# comment out the following line for switching off Java "System.out" displaying in the IDE window
#UDPport=12345
[DebugAgent delay timer]
# settings for Debug Agent delay timer in ms
#DATimer=2000
I send At command to terminal AT^SCFG? and get answer:
^SCFG: "AutoExec","0","0","0","0",""
^SCFG: "AutoExec","0","1","0","0","","000:00:00","000:00:00"
^SCFG: "AutoExec","0","1","1","0","","000:00:00","000:00:00"
^SCFG: "AutoExec","0","1","2","0","","000:00:00","000:00:00"
^SCFG: "GPRS/ATS0/withAttach","on"
^SCFG: "GPRS/AutoAttach","disabled"
^SCFG: "GPRS/PersistentContexts","0"
^SCFG: "GPRS/RingOnIncomingData","off"
^SCFG: "MEopMode/Airplane","off"
^SCFG: "MEopMode/Airplane/OnStart","off"
^SCFG: "MEShutdown/OnIgnition","off"
^SCFG: "PowerSaver/Mode9/Timeout","20"
^SCFG: "Radio/Band","3","15"
^SCFG: "Radio/OutputPowerReduction","3"
^SCFG: "Serial/USB/DDD","0","0","0409","0681","0034","Siemens AG Wireless Modules","XT75",""
^SCFG: "Tcp/BufSize","5200"
^SCFG: "Tcp/IRT","3"
^SCFG: "Tcp/MR","10"
^SCFG: "Tcp/OT","6000"
^SCFG: "Tcp/SAck","1"
^SCFG: "Tcp/TTcp","0"
^SCFG: "Tcp/WithURCs","on"
^SCFG: "Trace/Syslog/OTAP","0"
^SCFG: "Userware/Autostart","0"
^SCFG: "Userware/Autostart/AppName",""
^SCFG: "Userware/Autostart/Delay","0"
^SCFG: "Userware/DebugInterface","192.168.0.21","192.168.0.22","0"
^SCFG: "Userware/Passwd"
^SCFG: "Userware/Mode","debug","a:/Project02.jar","2000"
^SCFG: "Userware/Stdout","UDP","2000"
^SCFG: "URC/CallStatus/CIEV","restricted"
^SCFG: "URC/CallStatus/SLCC","verbose"
^SCFG: "URC/Datamode/Ringline","off"
^SCFG: "URC/Ringline","local"
^SCFG: "URC/Ringline/ActiveTime","2"
OK
Please help me.
Thanks.Hello,
I would like to know if you could debug?
That's the same problem what I have.
At the moment I have the DSB75 and the XT75 module I don't know what else I can to to run the program under debug.
OS: Win XP
eclipse-SDK-3.3.1.1
eclipseme.feature_1.7.7
Regards,
NOVI -
Hi, i have a problem to compile a servlet, i will try to explain my problem easily...
i have a JavaBena class int he directory.....C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes......and i have compiled it by DOS commands, everyhting has gone well!
i have a Servlet class in the same directory where it situated the JavaBean. i compile the Servlet as well as i have done with the Javabean, by DOS commans, including the Tomcat servlet api.
this is the command which i use to compile the servlet.......javac ServletRegistraUtente.java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar".....
but everything i get this error...
C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>javac ServletRicercaUtente
.java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"
ServletRicercaUtente.java:20: cannot find symbol
symbol : class BeanRicercaUtente
location: class ServletRicercaUtente
^
ServletRicercaUtente.java:20: cannot find symbol
symbol : class BeanRicercaUtente
location: class ServletRicercaUtente
BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
^
2 errors
C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>
these are the 2 classes....
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import JavaBean.BeanRicercaUtente;
public class ServletRicercaUtente extends HttpServlet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
ServletContext sc;
RequestDispatcher rd;
try
BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
request.setAttribute("m_BeanRicercaUtente", m_BeanRicercaUtente);
String codiceFiscale = request.getParameter("codice");
m_BeanRicercaUtente.effettuaRicerca(codiceFiscale);
sc = getServletContext();
rd = sc.getRequestDispatcher("/risposta.jsp");
rd.forward(request, response);
catch(Throwable theException){}
import java.sql.*;
public class BeanRicercaUtente
String nome, cognome, indirizzo, telefono;
public void effettuaRicerca(String codiceFiscale)
try
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://.................";
Connection con = DriverManager.getConnection(url);
Statement cmd = con.createStatement();
String qry = "SELECT ..................";
ResultSet res = cmd.executeQuery(qry);
while (res.next())
cognome = res.getString(1);
nome = res.getString(2);
indirizzo = res.getString(3);
telefono = res.getString(4);
res.close();
cmd.close();
con.close();
catch (SQLException e)
e.printStackTrace();
catch (ClassNotFoundException e)
e.printStackTrace();
i would be glad to get help about it...! :) thanks!i am sorry, but in the first class i have not written "import JavaBean.BeanRicercaUtente;"
i have only these imports...
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*; -
Debug 2 servlets at the same time please help!!!!
I am using JDeveloper 3.1 and trying to Debug 2 servlets at the same time. I can debug either servlet individually, but I cannot seem to call Servlet 2 from Servlet1 while debugging. I keep getting Web-to-go cannot find URL. What am I doing wrong.
Whenever I run a servlet in the debugger, the url shows: http://<myserver>/servlets/servlet regardless of the name of the servlet.
How do I debug 2 servlets at the same time.Hi,
It depends on how you call the second servlet from the first. You want to make sure to use a relative URL.
For example, if both of your compiled servlet classes are in JDEV_HOME\myclasses\ServletProject, then make sure to call servlet2 from servlet1 directly. If servlet2 is in JDEV_HOME\myclasses\OtherServlets, then you want to use '..\OtherServlets\servlet2'
I'm not sure why it resolves the url to servlets\servlet for everything. -
Problem about debugging system
Hi, all:
I meet a problem when debug my program from se38, It says 'Error during interprocess communication; Debugger will be closed . Message Number TPDA151'.
How can I resolve this problem?
Thanks in advance.Hi,
There must be SM21 logs , to figure out .
You can validate below oss notes.
Note 981211 - HTTP debugging with the new debugger is terminated.
Regards
Nagaraju -
Problem while building jsp/servlet in j2me
Hi friends,
I'm building Servlet in j2me.When i run this Servlet on web browser the Servlet running fine.But while in application when i used
conn = (HttpConnection)Connector.open( url );
where url = "http://localhost:8080/servlets-examples/hits"
It hangs ,the debugger stuck at this method .It didn't throw any Exception also.
Whats the problem?how could i resolve this issue?
Note:
I've used the follwing tutorial
http://developers.sun.com/techtopics/mobility/midp/articles/tutorial2/
to build servlet in MIDlet.
Regards,
Sachin Warang.hi friends,
I debug the code while doing so i realised that it throwing SecurityException .So edit the preferences>
where in security i've change it to untrusted and restore the settings.
After clicking on OK .
The application works fine.
Regards,
Sachin Warang. -
How to use jdb for debugging a servlet?
I'm using Apache/JServ with jdk 1.4 (via Textpad on win2K SP 3).
The 'gospel' I'm trying to follow is:
'Start the server manually and record the password for remote debugging
(this is displayed on the console).'
'Start the Java debugger:'
'jdb -host your_host -password the_password'
'You should be able to debug your Java classes now using the jdb
command.'
My problem is that I can't find the password from Apache.
I normally start/restart apache as a windows Service.
If I start it from DOS I get:
'C:\orant9i\Apache\Apache>apache -k start'
'Oracle HTTP Server Powered by Apache/1.3.12 (Win32) ApacheJServ/1.1
mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.24 running...'
I've searched the log, conf & property files but can't find any password.
I've also searched the Apache website for 'jdb' without luck.
I've printed out (and read!) the 'Using Apache with MS Windows' manual.
I did a Google:
--Someone suggested starting Apache using using the -X flag, but I don't
seem to have this option.
--Someone else suggested changing jvm12.conf, but I don't have one.
I have tried the following, just-in-case I don't really need a password,
but it doesn't tell me a lot, and I would appreciate some help:
JDB -sourcepath E:\javaPackages org.apache.jserv.JServServletManager
C:\orant9i\Apache\Apache>JDB org.apache.jserv.JServServletManager
Initializing jdb ...
> run
run org.apache.jserv.JServServletManager
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started:
Exception occurred: java.lang.ClassNotFoundException (uncaught)"thread=main", java.net.URLClassLoader$1.run(), line=199 bci=72
main[1] list
Source file not found: URLClassLoader.java
main[1]
Thanks,
Peter.
Posted to alt.apache.configuration, comp.lang.java, http://groups.yahoo.com/group/win-apache and
comp.infosystems.www.servers.misc with no responseHello
You wrote:
I added the following to jserv.properties:
wrapper.bin.parameters=-Xdebug
wrapper.bin.parameters=-Xrunjdwp:transport=dt_socket,address=2930,suspend=n,server=y
and it ran the servlet okay.Fine so far. This means your debugee VM is started and running. The "suspend=n" means it
will start running without waiting for a debugger to attach... so you can attach later whenever you
decide to debug. Note that 'later' could be weeks later, or possibly never.
Now: Time to attach jdb to the victim/debugee process you started above.
You wrote:
But I get the following when I try to start jdb:
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=2930 org.apache.jserv.JServServletManager
gives:
Cannot specify command line with connector:
com.sun.jdi.SocketAttach:hostname=localhost,port=2930,
and
jdb -attach localhost:2930 org.apache.jserv.JServServletManager
gives:
Cannot specify command line with connector: com.sun.jdi.SharedMemoryAttach:name=localhost:2930,The problem here is that you are trying to supply too much information to jdb.
When you are using the attach connectors, all you need to supply is the
host name and socket (for the socket connectors), or the name of the shared memory
area (for the shared memory connector). The connectors you tried above are throwing
an error because you are trying to supply something extra (the class name).
When doing an attach, the debugee VM is already launched. The debugger will
attach to it and inspect the classes loaded.
If you are still running with the wrapper.bin.parameters you listed above,
then all you need to connect with jdb is:
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=2930 You should get a jdb prompt, and you will be able to inspect the debugee
VM by entering commands such as threads and classes. Typically
the next thing would be to set some breakpoints (stop in package.class.method,
or stop at package.class:line. Then restart the debugee with a resume. -
Problem in debuging jasper reports and ADF
Hi
I am using JDeveloper 11.1.2.2.0. Inside I created Fusion Web Application ADF, and on the index page created Go button. Now I created Servlet with doGet methode and conncected it to Go button. It is working OK.
Now I want to run simple jasper report from servlet. Jasper report is based on empty dataset. Here is servlet code:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletOutputStream servletOutputStream =response.getOutputStream();
InputStream reportStream = getServletConfig().getServletContext()
.getResourceAsStream("C:/Users/myDomain/Desktop/Reporting/ReportPDFPrazan.jasper");
try
JasperRunManager.runReportToPdfStream(reportStream,servletOutputStream,null, new JREmptyDataSource());
response.setContentType(CONTENT_TYPE);
servletOutputStream.flush();
servletOutputStream.close();
catch (JRException e)
// display stack trace in the browser
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
response.setContentType("text/plain");
response.getOutputStream().print(stringWriter.toString());
When I hit Go button here what I get:
java.lang.NullPointerException
at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2265)
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2278)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
at java.io.ObjectInputStream.(ObjectInputStream.java:279)
at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.(ContextClassLoaderObjectInputStream.java:53)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:214)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:632)
at net.sf.jasperreports.engine.JasperRunManager.runToPdfStream(JasperRunManager.java:428)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:849)
at view.com.lanaco.servlets.PrviServlet.doGet(PrviServlet.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
and so on(I can put whole stack if necery)
I also imported this libraries inside ViewControl project:
Jasperreports-4.7.1.jar
Commons-beanutils-1.8.0.jar
Commons-collections-2.1.1.jar
Commons-digester-2.1.jar
Commons-logging-1.1.1.jar
IText-2.1.7.jar
Groovy-all-1.7.5.jar
Poi-3.7-20101029.jar
Can someone help me with debuging. Please
Edited by: MarcusO on 2012.10.23 05:18I found solution. It should be used like this:
InputStream reportStream = new FileInputStream(new File("C:/Users/myDomain/Desktop/Reporting/ReportPDFPrazan.jasper"));
So problem was in input stream. It works fine now. -
Enable JSSE Debugging in servlet?
Hi everyone,
I read from an article that we can enable the JSSE debugging using the following command
java -Djavax.net.debug=all MySSLApp
Is it possible to enable such debugging utility inside the code of a servlet?
Thanks
FengYes, you can enable this in a servlet, no problem. I am assuming that you are using iPlanet 6.X. Then in magnus.conf, you can capture the stdout and stderr to the errors log, and that will contain the "transcript" of your ssl handshakes, etc..... or whatever debugging output you want.
The config lines to capture stdout and stderr to the errors log are:
LogStdout on
LogStderr on
You can also configure java logging to go to places other than stdout and stderr, but for that you'll have to ask someone else.... :-)
Maybe you are looking for
-
Photo image : size reduction software
HI ! I want to reduce sizes of photo images i.e. jpeg, gif files of few GB's into less than 100KB. Need free / paid software compatible to MAC OS X 10.6.8.
-
How much does it cost for an iphone4 screen repair?
How much does it cost for an iphone 4 screen repair?
-
Embedded PDF in fixed layout ePub
Can anyone confirm if embedded pdf's are supported in a fixed layout ePub? If I create a simple free flow ePub (version 2 or 3), embed a pdf in the ePub and have a link to the pdf on a page in the ePub, clicking the link opens the pdf. However if I m
-
The track pad on my MacBook Pro 15" (Late 2009) when trying to drag and drop files stays continously selected and never lets me drop them into the new folder. This all started happening after install of the OS X Mountain Lion. I have already tried
-
I export an image in Aperture 3 but it doesn't save the alterations.
I'm new to Aperture after using Photoshop for years. After I have made my alterations in Aperture 3 (instead of the save function in Photoshop) I export the 'version' as full jpeg however the alterations I've made do not appear in the exported jpeg.