Bob Backlund

Ranch Hand
+ Follow
since Jun 05, 2003
Merit badge: grant badges
For More
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 Bob Backlund

I have a small problem (bug/feature/annoyance) with SQL server and Java.

I have two tables, onr called tblCustomers one called tblReps, both have columns in them called: fname, sname, email etc... I am running a SQL quary in Java which retrieves all the details of a customer and their rep' . Obviously I can't just have
String Fname = resultset.getString("fname");
as this would be ambigious, so i thought I'd use
String CustFname = resultset.getString("tblCustomer.fname");
String RepFname = resultset.getString("tblReps.fname");

problem solved....

NO! I now get:-
com.microsoft.sqlserver.jdbc.SQLServerException: The column name tblCustomer.fname is not valid.


What the hell am I mean t to do? I don't want to break the SQL into several little queries, that will get messy. Is the a fix to this or is it a FKUP in the MS SQL Driver? (driver - sqljdbc.jar)
17 years ago
Just a quicky to as, is it possible to call an 'alert' style popup from a Servlet, like the Javascript ones? If so how?

Cheers
17 years ago
Hi

Hoping you can help...

I have an admin enter page which has 2 dropdown boxes, one with all the staff available and one with all the different jobs they can do. At the moment the two dropdowns are very long (one has 188 users, the other 200+ jobs), but on average a user can perform only around 6 of those jobs each.

What I would like it to do is somehow change it so that when you select a user the second dropdown only shows jobs that user can do.

I have the users and jobs in a SQL DB and a matrix table linking users to jobs. So I need some sort of Javascript function which will dynamically create a SQL query to search for all jobs under thet user's ID.

I'm presuming the onChange() function will come into effect here...

Cheers
[ March 28, 2006: Message edited by: Bear Bibeault ]
17 years ago
JSP
It's OK, I've sorted it (it's Friday), the substring has to be from 1,8 NOT 0,8
Quite simple really, I have a table with a shift_id which is generated by date (ddmmyyyhhmmss) plus '_userid' (example 24032006132015_01). I need to check that a user doesn;t have a shift time for today already entered, so I'm checking the substring of the first 8 characters to see if they match todays date, here is my SQL command:

[SELECT * FROM tblTimeSheet WHERE (SUBSTRING(shift_id, 0, 8) = '24032006')]

So how come this returns NULL when there are clearly 5 rows in my DB which have 24032006 at the start of the shift_id?
Hi guys,

Just a quicky. Anyone know of a way to replace the ugly Internet Exploere "image not found" red X with something a little nicer?

Basically I have a page which will list a number of images but some of them may no longer exist, so I want the page to display a default 'image unavailable' pic instead of the ugly red X

Cheers
Example please, I'm not quite sure I follow.
18 years ago
JSP
Hi guys, just a quicky problem (I hope).

I have a simple JSP page which displays the results of a SQL query, clikcing on one of the results opens a second page where you can update details of that record. What I need is a back button which will take you back to the seach results with updated details.

(i have done with a simple back button like so -- javascript: history.go(-1)

The problem is the search results page is cached and therefore displaying the details from BEFORE the changes were made (still with me?). What I need is a way of refreshing the search results page so that the new details are displayed.

Cheers
18 years ago
JSP
Yes, I have an include file called init.jsp which declares this bean in every page.
18 years ago
Here is an exampe of the errors I am getrting:

D:\Development\Dev\src>JAVAC -d D:\Development\Dev\classes uk\co\domain\beans\*.java

D:\Development\Dev\src>JAVAC -d D:\Development\Dev\classes uk\co\domain\controllers\*.java
uk\co\domain\controllers\FunctionController.java:8: package uk.co.domain.beans does not exist
import uk.co.domain.beans.UserDataBean;
^
As you can see the bean package (which had no imports) copiles fine, but the controllers package does not,
claiming that "package uk.co.domain.beans does not exist" which is funny as it's just compiled that package.
As I say I do not get this if I compile the code using JDK1.5, but because of WAS 5.0 I have rto use JDK1.4
or below.
18 years ago
Classes are saved under the following:

D:\Development\Dev\web\WEB-INF\classes\uk\co\domain
in folders called:
beans
controllers
database
servlets
utils

Source code is under:

D:\Development\Dev\src\uk\co\domain
is same fodler names as above

My compiler batch file is as follows:

CD\Development\Dev\src
JAVAC -d D:\Development\Dev\web\WEB-INF\classes uk\co\domain\beans\*.java
JAVAC -d D:\Development\Dev\web\WEB-INF\classes uk\co\domain\controllers\*.java
JAVAC -d D:\Development\Dev\web\WEB-INF\classes uk\co\domain\database\*.java
JAVAC -d D:\Development\Dev\web\WEB-INF\classes uk\co\domain\servlets\*.java
JAVAC -d D:\Development\Dev\web\WEB-INF\classes uk\co\domain\utils\*.java

My config file as follows:
SET JAVA_HOME=C:\Java\j2sdk1.4.2_07
SET JAVA_BIN=C:\Java\j2sdk1.4.2_07\bin
SET JAVA_JRE=C:\Java\j2sdk1.4.2_07\jre
SET DEV_LIBS=D:\Development\Dev\web\WEB-INF\lib\

SET PATH=%PATH%;%JAVA_HOME%;%JAVA_JRE%;%JAVA_BIN%
SET CLASSPATH=%CLASSPATH%;%JAVA_LIBS%;%DEV_LIBS%\servlet.jar
18 years ago
D:\Development\Dev\web\WEB-INF\classes\uk\co\domain
in folders called:
beans
controllers
database
servlets
utils

Source code is under:
D:\Development\Dev\src\uk\co\domain
is same fodler names as above
18 years ago
Hi

I was wondering if someone could help me out. I have just written a quite simple java system which consists of about 12 classes under 5 packages (folders). Now if I compile this in JDK 1.5 (which it was quite natural to choose the latest JDK) eveything is fine, all the classes compile, no problem. BUT... IBM WAS 5.0 can't handle WebApps compiled using JDK1.5, so I had to download the previous version, JDK1.4 (j2sdk1.4.2_07 to be precise). The problem is now when I go to compile the same classes in the same folder structure, I get loads of error like:

uk\co\domain\servlets\SoftwareUpdateServlet.java:10: package uk.co.domain.database does not exist
import uk.co.domain.database.DBConnectionPool;

This happens for every import of every class I have, but like I say. Compile it in JDK1.5.0 and it's fine.

Anyone know of any problems with 1.4 and packages?

Cheers
18 years ago
Hi guys,

I'm looking to create a secure webapp using Java. It will have a very basic username/password login
which will redirect to a 'secure' area.

You can only access the pages under this secure area if you are logged in, otherwise you will be redirected
to the login JSP.

Now this is the first time I've tried this and I have collected my ideas and info from various webpages, so it is
possible i'm completely off track here.

What I've tried to do is write two small pieces of code, one is in the LoginServlet which creates a cookie, with a
name and userid (encoded). the other piece is in an 'include file' which every page under the secure area uses.

This simply looks to see if the cookie exists for that user and if it does fine, otherwise redirect to the login page.

Seems quite straight forward to me, but the problem is, if I go directly to a 'secure' apge (and there is no
cookie present) the page still opens up.

Here are the two pieces of code

LoginServlet code to create cookie:


try {
String strUserID = String.valueOf(iUserID);
Cookie cookie = new Cookie("UserID",URLEncoder.encode(strUserID));
cookie.setMaxAge(3600); // expires after 1 hour
cookie.setPath("/");
cookie.setValue(strUserID); //always update in case change of ID
response.addCookie(cookie);
} catch (Exception exC) {
System.out.println("[LoginServlet] Failed to create cookie: " +exC);
session.invalidate();
response.sendRedirect("/login.jsp");
throw new ServletException(exC.getMessage());
}

Include file code, to check cookie exists:
try {
session = request.getSession(true);
Cookie cookies[] = request.getKookies();
if (cookies != null) {
for(int i=0, n=cookies.length; i < n; i++) {
Cookie cookie = cookies[i];
if (cookie.getName().equals("UserID")) {
strUserID=cookie.getValue();
session.putValue("stUserID",strUserID);
System.out.println("ession cookie found, user is logged in.");
} else {
response.sendRedirect("/login.jsp");
System.out.println("No session cookie for user, user must first log in.");
}
}
}
} catch (Exception ex) {
System.out.println("Error finding cookie: " +ex);
}



As i say i could be completely off track with this, but I think it should be right.
19 years ago
JSP
Cheers everyone, that appears to solve my problem.
19 years ago