Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Brandon Potter

Greenhorn
+ Follow
since Jul 22, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brandon Potter

I am having trouble configuring my web.xml file in the web app directory of tomcat.

When I add the servlet mapping and such as below ALL of my jsp pages then throw a 404 error.

NEW WEB.XML


OLD WEB.xml




And yes, my Servlet is called Servlet1 (trying to reorganize a project to better fit MVC)

EDIT*
Well, I was reading more and I realised something (newish to programming, at least in java) What is the best method for packaging your classes?
I tried doing something with it earlier today and in doing so, had some problems, so in just learning I cant leave it in a default package means I need to fix that.


9 years ago
@ paul the ID there was from something old that I had been trying with AJAX that has henceforth been edited out.
The string concatenation is definitely a possible worry, however since I new to prepared statements still, and this is an internal only database, which is to be passed along to a higher power and remade from mySQL into an Oracle database to meet the workplaces standards ( client needs a roughed in version working yesterday, since this project got dropped by someone and not picked up and it is mandatory to his research) so until the "proper" db is built and designed I have about 3 weeks to build a hacked together one for him to use in the meantime. I am using this as a learning experience.

@ Bear - that article is REALLY helpful, as I am new to web programming with my only experience from school where my proff obviously taught us outdated methods, such articles as that are GREAT.
The DB access in the view I know is a horrible thing, threw it in just to test the page, got a proper back end login for it that will be applied when I finish the page (just my way of working from the way I was taught, bad I know).

I am obviously still new to this, building a basic interface for a database for someone, however, if it would be possible I would be very appreciative if you were to expound on the comment "Java scriptlets in a JSP. Considered a poor practice for almost 10 years now." I was taught this way at school, and since I am self learning alot more since, and constructive ctritcism is always welcome.

Thanks
And for the record, once I get some of the other pages done, and used as examples to our internal client their will be alot of cleaning in that code done, got a list of some of it, but I just copied a bunch of code from my old school work and from there updated it to make it work for now.
Feel free to let me know any problems you can see, this is a very rough just get the ideas down and running then code clean after draft.
THANKS A TON!!!


so the load command overwrite the code fragment I am looking for! it does not append it in!

THANKS A TON GUYS!!!
That is the page that is generating the code fragment.
What I am looking to do is this:

I have a jsp page with a table.

I have a button on the page that when the user clicks check, I want the computer to do an ajax style update to that table and then from a different page, load up another (identically named table) which may or may not contain data (if data is found etc) . The reason I have the remove code there is so that if someone hits check twice in the same session, it wont merely append a second copy of the table, but will instead remove the orignal, and then add in the new.

At this point, I am having the table removed, however it is not loading up the table from the other page.


Xen
http://api.jquery.com/load

loading fragments section

The space is there on purpose.
Hi,

I am working on a program, where I have a table in my webpage, which will be autofilled. More specifically, what I want to do, is input a value, and then have the user click a button to check the name against the database, and if it is in there, return a table of filled fields if not, return an empty table to be filled in.

I have the verification code done, however my problem is getting the table to load from the other page in an ajax style (ie no refresh)

here is what I have, could you guys lemme know what I might be doing? thanks.
I have the feeling that this has something to do with setting up the context files, and doing that properly, but I am hungover, and right now the context files documentation is just not making sense to me at all, I suppose I should move this post now to a different forum......
Thanks!
10 years ago
JSP
Ok, thanks for that tip, however now is where the trouble starts. I can not for the life of me find out how to actually setup the socket on windows 7, I have spent the last couple hours trying to find a guide on that part.

This is my first time setting up a mySQL database, and this part is really turning out to be a pain! here is a section of a log file, that I think is showing exactly what the problem is, I just don't know how to fix it.

Any help would be greatly appreciated, and thank you all.


Version: '5.1.56-community-log' socket: '' port: 3306 MySQL Community Server (GPL)
110723 4:02:55 [Note] C:\Program Files\BitNami Apache Tomcat Stack\mysql\bin\mysqld.exe: Normal shutdown

110723 4:02:55 [Note] Event Scheduler: Purging the queue. 0 events
110723 4:02:55 [Note] C:\Program Files\BitNami Apache Tomcat Stack\mysql\bin\mysqld.exe: Shutdown complete

110723 4:03:46 [Note] Plugin 'FEDERATED' is disabled.
110723 4:03:47 InnoDB: Error: unable to create temporary file; errno: 2
110723 4:03:47 [ERROR] Plugin 'InnoDB' init function returned error.
110723 4:03:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
110723 4:03:50 [Note] Event Scheduler: Loaded 0 events
110723 4:03:50 [Note] C:\Program Files\BitNami Apache Tomcat Stack\mysql\bin\mysqld.exe: ready for connections.
Version: '5.1.56-community-log' socket: '' port: 3306 MySQL Community Server (GPL)
10 years ago
JSP
I have a database built in mySQL on an internal network, using a BitNami Tomcat stack enviroment on a windows 7 enterprise machine, and am attempting to build a web interface for it. I know jsp, and have done a good amount of work in it, however I am having problems connecting to my database. FOllowing is example of the code, errors, and anything else I can think of, please let me know what you think.


Section of code attempting to connect with:
<%@ page import="java.sql.*" %>
<HTML>
<HEAD>
<TITLE>Query Results Using JSP</TITLE>
</HEAD>
<BODY>
<p>RAWR</p>
<% try
{ // Load driver class
Class.forName("com.mysql.jdbc.Driver");
}
catch (java.lang.ClassNotFoundException e) {
System.err.println("ClassNotFoundException: " +e);
}
%>

<%
Connection con = null;
String url = "jdbc:mysql://bcsumm624686:3304/Virus;";
String uid = "PUBLIC";
String pw = "publicAccess";
out.println("hmmmmm1");
try {
out.println("hmmmmm2");
out.println(url);
out.println(uid);
out.println(pw);
con = DriverManager.getConnection(url, uid, pw);
out.println("hmmmmm3");
Statement stmt = con.createStatement();
ResultSet rst = stmt.executeQuery("SELECT * FROM virus");
out.print("<TABLE><TR><TH>Name</TH>");


log fil from my SQL
C:\Program Files\BitNami Apache Tomcat Stack\mysql\bin\mysqld.exe, Version: 5.1.56-community-log (MySQL Community Server (GPL)). started with:
TCP Port: 3306, Named Pipe: MySQL
Time Id Command Argument

ERRORS:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /VirusList.jsp at line 28

25: out.println(url);
26: out.println(uid);
27: out.println(pw);
28: con = DriverManager.getConnection(url, uid, pw);
29: out.println("hmmmmm3");
30: Statement stmt = con.createStatement();
31: ResultSet rst = stmt.executeQuery("SELECT * FROM virus");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.VirusList_jsp._jspService(VirusList_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1122)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2260)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
sun.reflect.GeneratedConstructorAccessor8.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
java.sql.DriverManager.getConnection(DriverManager.java:582)
java.sql.DriverManager.getConnection(DriverManager.java:185)
org.apache.jsp.VirusList_jsp._jspService(VirusList_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1122)
com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2181)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
sun.reflect.GeneratedConstructorAccessor8.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
java.sql.DriverManager.getConnection(DriverManager.java:582)
java.sql.DriverManager.getConnection(DriverManager.java:185)
org.apache.jsp.VirusList_jsp._jspService(VirusList_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

java.net.ConnectException: Connection refused: connect
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
java.net.Socket.connect(Socket.java:529)
java.net.Socket.connect(Socket.java:478)
java.net.Socket.<init>(Socket.java:375)
java.net.Socket.<init>(Socket.java:218)
com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:293)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2181)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:787)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
sun.reflect.GeneratedConstructorAccessor8.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:357)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
java.sql.DriverManager.getConnection(DriverManager.java:582)
java.sql.DriverManager.getConnection(DriverManager.java:185)
org.apache.jsp.VirusList_jsp._jspService(VirusList_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.
10 years ago
JSP