Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old September 27th, 2002, 03:51 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Sure. Just post 'er on up.

It's 2am here now, though, so I probably won't get to until tomorrow

Reply With Quote
  #17  
Old September 27th, 2002, 04:00 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this is the codes for the interface page

-----------------------------------------------------------------------------------

<%@ page language="java" import="com.elixirtech.report.server.client.*, java.util.*, java.io.*, java.util.zip.*, java.sql.*, java.lang.Object, java.util.Date, java.io.File,java.lang.Object, java.util.Calendar, java.util.GregorianCalendar, java.text.Format, java.text.DateFormat, java.text.SimpleDateFormat, java.text.*"%>
<jsp:useBean id="ReportClient" scope="session"
class="com.elixirtech.report.server.client.ReportClientBean" />

<html>
<head>
<title>Adhoc</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
//connection.jsp contains information of database server
<%@ include file="connection.jsp" %>
<%String site = null;%>
<%String org = null;%>
<%String publicholiday = null;%>
<%
Connection connection = null;
Statement statement = null;
Statement statement2 = null;
Statement statement4 = null;
ResultSet rs = null;
ResultSet rs2 = null;
ResultSet rs4 = null;
//date
GregorianCalendar gc = new GregorianCalendar();
// get the date
Date d = gc.getTime();
Date d2 = gc.getTime();
Date d3 = gc.getTime();
Date d4 = gc.getTime();
Date d5 = gc.getTime();
//current date
long time1 = d.getTime();
d.setTime(time1);
//effdate = currentdate + 1
long time2 = d2.getTime()+86400000;
d2.setTime(time2);
//effdate = currentdate + 2
long time3 = d3.getTime()+86400000+86400000;
d3.setTime(time3);
//effdate = currentdate + 3
long time4 = d4.getTime()+86400000+86400000+86400000;
d4.setTime(time4);
long time5 = d5.getTime()+86400000+86400000+86400000+86400000;
d5.setTime(time5);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf2 = new SimpleDateFormat("EEE");
SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yyyy");

String d1 = sdf3.format(d);
String effdate = sdf.format(d2);
String effdate2 = sdf3.format(d2);
String eff = sdf2.format(d);
String eff2 = sdf2.format(d3);
String finaleffDate;
String finaleffDate2;
String nonworkday="";
boolean ph=false;

Class.forName("org.gjt.mm.mysql.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
statement2 = connection.createStatement();
statement4 = connection.createStatement();

rs = statement.executeQuery("Select Site FROM Site");
rs2 = statement2.executeQuery("Select distinct Organisation FROM Organisation");
rs4 = statement4.executeQuery("Select Date FROM Sys_Public_Holiday");

while(rs4.next())
{
publicholiday=rs4.getString(1);
if(effdate.equals(publicholiday))
{
ph=true;
break;
}
else
{
ph=false;
}
}
if(eff.equalsIgnoreCase("Fri"))
{
finaleffDate = sdf.format(d4);
finaleffDate2 = sdf3.format(d4);
}
else if(eff.equalsIgnoreCase("Sat"))
{
finaleffDate = sdf.format(d3);
finaleffDate2 = sdf3.format(d3);
}
else if(eff.equalsIgnoreCase("Sun"))
{
finaleffDate = sdf.format(d2);
finaleffDate2 = sdf3.format(d2);
}
else if(ph == true)
{
if(eff2.equalsIgnoreCase("Sat"))
{
finaleffDate = sdf.format(d5);
finaleffDate2 = sdf3.format(d5);
}
else if(eff2.equalsIgnoreCase("Sun"))
{
finaleffDate = sdf.format(d4);
finaleffDate2 = sdf3.format(d4);
}
else
{
finaleffDate = sdf.format(d3);
finaleffDate2 = sdf3.format(d3);
}
}
else
{
finaleffDate = effdate;
finaleffDate2 = effdate2;
}
%>


<body bgcolor="#0099CC" text="#FFFFFF" link="#FFFFFF" vlink="#CC6600" alink="#FFFFFF">
<p><font color="#FFFFFF" size="4"><b><font size="5">Request for New Account Creation</font></b></font>
</p>
<p><font color="#FFFF00"><b>*Mandatory Fields</b></font></p>


<form name="form1" method="post" action="AdhocRequestCheck.jsp">
<div align="center">
<p align="right"><font size="2">Request Date :<input type="hidden" name="reqdate" value="<%= d1%>"> <%= d1%></font></p>
<p align="left"><u>Organisation Details</u></p>
<table width="88%" border="1" height="30">
<tr>
<td width="34%" height="15"> <font color="#FFFF00">*</font> Organisation:
<select name="select">
<%
while(rs2.next()){
org = rs2.getString(1);
%>
<option> <%= org%> </option>
<%}

%>
</select>
</td>
<td width="66%" height="15"><font color="#FFFF00">*</font> Site:
<select name="site">
<%
while(rs.next()){
site = rs.getString(1);
%>
<option><%= site%></option>
<%}
rs.close();
statement.close();
//connection.close();
%>
</select>
</td>
</tr>
</table>
<div align="left">
<p><br>

<u>User Details</u> </p>
<table width="88%" border="1" align="center">
<tr>
<td width="16%"> <font color="#FFFF00">*</font> First Name:</td>
<td width="31%">
<input type="text" name="fn" maxlength="50">
</td>
<td width="14%"> <font color="#FFFF00">*</font> Last Name:</td>
<td width="39%">
<input type="text" name="ln" maxlength="50">
</td>
</tr>
<tr>
<td width="16%">Designation:</td>
<td width="31%">
<input type="text" name="design" maxlength="70" value="Teacher">
</td>
<td width="14%"> Eff Date:<br>
<font size="1">(YYYY-MM-DD)</font></td>
<td width="39%">
<input type="hidden" name="effdate" maxlength="10" value="<%= finaleffDate%>"><%= finaleffDate2%>
</td>
</tr>
<tr>
<td width="16%"><font color="#FFFF00">*</font> NRIC:</td>
<td width="31%">
<input type="text" name="Nric" maxlength="9">
</td>
<td width="14%">Chinese Name:</td>
<td width="39%">
<select name="chinese">
<option value=Y>Yes</option>
<option value=N>No</option>
</select>
</td>
</tr>
</table>
<p align="right">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</p>
</div>
</div>
</form>
<p><br>
</p>
<p>&nbsp;</p>
</body>
</html>

-----------------------------------------------------------------------------------

Reply With Quote
  #18  
Old September 27th, 2002, 04:04 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this is the codes for the checks

<%@ page language="java" import="java.util.*, java.io.*, java.util.zip.*, java.sql.*, java.lang.Object, java.util.Date"%>
<%@ include file="connection.jsp" %>

<%
String validate = request.getParameter("sitecode");
String validate2 = request.getParameter("site");
String firstname = request.getParameter("fn"); // insert as AA_UserName
String lastname = request.getParameter("ln"); // insert as AA_UserName
String AA_Name = firstname + lastname;
String designation = request.getParameter("design");
String reqDate = request.getParameter("reqdate");
String effDate = request.getParameter("effdate");
String nric = request.getParameter("Nric");
String chinese = request.getParameter("chinese");

//for checks
String firstNameLower = firstname.toLowerCase();
String lastNameLower = lastname.toLowerCase();

String salutations = "mrs";
String salutations2 = "mrs.";
String salutations3 = "(mrs)";

String salutations4 = "mr";
String salutations5 = "mr.";
String salutations6 = "(mr)";

String salutations7 = "miss";
String salutations8 = "miss.";
String salutations9 = "(ms)";

String salutations10 = "mdm";
String salutations11 = "mdm.";
String salutations12 = "(mdm)";

String fullname = firstNameLower+lastNameLower;
boolean checkbin = fullname.indexOf("bin") > -1;
boolean checkspecialword1 = fullname.indexOf("binte") > -1;
boolean checkspecialword2 = fullname.indexOf("binti") > -1;
boolean checkspecialword3 = fullname.indexOf("bte") > -1;
boolean checkspecialword4 = fullname.indexOf("d/o") > -1;
boolean checkspecialword5 = fullname.indexOf("s/o") > -1;
boolean checkspecialword6 = fullname.indexOf("w/o") > -1;
boolean checkspecialword7 = fullname.indexOf("a/l") > -1;
boolean checkspecialword8 = fullname.indexOf("d/0") > -1;
boolean checkspecialword9 = fullname.indexOf("s/0") > -1;
boolean checkspecialword10 = fullname.indexOf("w/0") > -1;
boolean checkspecialword11 = fullname.indexOf("a/1") > -1;
boolean checkspecialchar1 = fullname.indexOf("!") > -1;
boolean checkspecialchar2 = fullname.indexOf("@") > -1;
boolean checkspecialchar3 = fullname.indexOf("#") > -1;
boolean checkspecialchar4 = fullname.indexOf("$") > -1;
boolean checkspecialchar5 = fullname.indexOf("%") > -1;
boolean checkspecialchar6 = fullname.indexOf("^") > -1;
boolean checkspecialchar7 = fullname.indexOf("&") > -1;
boolean checkspecialchar8 = fullname.indexOf("*") > -1;
boolean checkspecialchar9 = fullname.indexOf("(") > -1;
boolean checkspecialchar10 = fullname.indexOf(")") > -1;
boolean checkspecialchar11 = fullname.indexOf("+") > -1;
boolean checkspecialchar12 = fullname.indexOf("=") > -1;
boolean checkspecialchar13 = fullname.indexOf("~") > -1;
boolean checkspecialchar14 = fullname.indexOf("`") > -1;
boolean checkspecialchar15 = fullname.indexOf("|") > -1;
boolean checkspecialchar16 = fullname.indexOf("<") > -1;
boolean checkspecialchar17 = fullname.indexOf(">") > -1;
boolean checkspecialchar18 = fullname.indexOf("?") > -1;
boolean checkspecialchar19 = fullname.indexOf("{") > -1;
boolean checkspecialchar20 = fullname.indexOf("}") > -1;
boolean checkspecialchar21 = fullname.indexOf("[") > -1;
boolean checkspecialchar22 = fullname.indexOf("]") > -1;
boolean checkspecialchar23 = fullname.indexOf(":") > -1;
boolean checkspecialchar24 = fullname.indexOf(";") > -1;

if (checkspecialword2)
{
out.print("BINTI found in name.");
}
else if (checkspecialword3)
{
out.print("BTE found in name.");
}
else if (checkspecialword4)
{
out.print("'d/o' found in name.");
}
else if (checkspecialword5)
{
out.print("'s/o' found in name.");
}
else if (checkspecialword6)
{
out.print("'w/o' found in name.");
}
else if (checkspecialword7)
{
out.print("'a/l' found in name.");
}
else if (checkspecialword8)
{
out.print("'d/0' found in name.");
}
else if (checkspecialword9)
{
out.print("'s/0' found in name.");
}
else if (checkspecialword10)
{
out.print("'w/0' found in name.");
}
else if (checkspecialword11)
{
out.print("'a/1' found in name.");
}
else
{
//check mandatory fields not null
if(!firstname.equals("") && !lastname.equals("") && !nric.equals(""))
{
//check that name does not contain salutations and special words
if(!firstNameLower.startsWith(salutations) && !firstNameLower.startsWith(salutations2) && !firstNameLower.startsWith(salutations3) && !firstNameLower.startsWith(salutations4) && !firstNameLower.startsWith(salutations5) && !firstNameLower.startsWith(salutations6) && !firstNameLower.startsWith(salutations7) && !firstNameLower.startsWith(salutations8) && !firstNameLower.startsWith(salutations9) && !firstNameLower.startsWith(salutations10) && !firstNameLower.startsWith(salutations11) && !firstNameLower.startsWith(salutations12) && !firstNameLower.endsWith(salutations) && !firstNameLower.endsWith(salutations2) && !firstNameLower.endsWith(salutations3) && !firstNameLower.endsWith(salutations4) && !firstNameLower.endsWith(salutations5) && !firstNameLower.endsWith(salutations6) && !firstNameLower.endsWith(salutations7) && !firstNameLower.endsWith(salutations8) && !firstNameLower.endsWith(salutations9) && !firstNameLower.endsWith(salutations10) && !firstNameLower.endsWith(salutations11) && !firstNameLower.endsWith(salutations12) && !lastNameLower.startsWith(salutations) && !lastNameLower.startsWith(salutations2) && !lastNameLower.startsWith(salutations3) && !lastNameLower.startsWith(salutations4) && !lastNameLower.startsWith(salutations5) && !lastNameLower.startsWith(salutations6) && !lastNameLower.startsWith(salutations7) && !lastNameLower.startsWith(salutations8) && !lastNameLower.startsWith(salutations9) && !lastNameLower.startsWith(salutations10) && !lastNameLower.startsWith(salutations11) && !lastNameLower.startsWith(salutations12) && !lastNameLower.endsWith(salutations) && !lastNameLower.endsWith(salutations2) && !lastNameLower.endsWith(salutations3) && !lastNameLower.endsWith(salutations4) && !lastNameLower.endsWith(salutations5) && !lastNameLower.endsWith(salutations6) && !lastNameLower.endsWith(salutations7) && !lastNameLower.endsWith(salutations8) && !lastNameLower.endsWith(salutations9) && !lastNameLower.endsWith(salutations10) && !lastNameLower.endsWith(salutations11) && !lastNameLower.endsWith(salutations12))
{
//check NRIC length = 9
try
{
//check NRIC length = 9
if (nric.length()==9)
{
//check NRIC 1st char = uppercase "S" or "F"
if(nric.substring(0,1).equals("S") || nric.substring(0,1).equals("F"))
{
//check NRIC middle 7 chars are digits
Integer.parseInt(nric.substring(1,8));
//check NRIC last char = uppercase "A" to "Z"
if(nric.substring(8,9).equals("A") || nric.substring(8,9).equals("B") || nric.substring(8,9).equals("C") || nric.substring(8,9).equals("D") || nric.substring(8,9).equals("E") || nric.substring(8,9).equals("F") || nric.substring(8,9).equals("G") || nric.substring(8,9).equals("H") || nric.substring(8,9).equals("I") || nric.substring(8,9).equals("J") || nric.substring(8,9).equals("K") || nric.substring(8,9).equals("L") || nric.substring(8,9).equals("M") || nric.substring(8,9).equals("N") || nric.substring(8,9).equals("O") || nric.substring(8,9).equals("P") || nric.substring(8,9).equals("Q") || nric.substring(8,9).equals("R") || nric.substring(8,9).equals("S") || nric.substring(8,9).equals("T") || nric.substring(8,9).equals("U") || nric.substring(8,9).equals("V") || nric.substring(8,9).equals("W") || nric.substring(8,9).equals("X") || nric.substring(8,9).equals("Y") || nric.substring(8,9).equals("Z"))
{
//if it is a chinese name
if(chinese.equalsIgnoreCase("Y"))
{
//is bin
if(checkbin)
{
out.println("Ok.");
}
//if it is binte
else if(checkspecialword1)
{
out.print("BINTE found in name.");
}
//is not bin or binte
else
{
out.println("Ok.");
}
}
//if it is not a chinese name
else
{
//if it is bin
if(checkbin)
{
out.println("Non chinese name should not contain 'bin'.");
}
//if it is binte
else if(checkspecialword1)
{
out.print("BINTE found in name.");
}
//if not bin or binte
else
{
out.print("Ok.");
}
}
}
else
{
out.println("NRIC last char should be a UPPERCASE ALPHABET.");
}
}
else
{
out.println("NRIC first char should be UPPERCASE S or F.");
}
}
else
{
out.println("NRIC total length not = 9.");
}
}
catch ( NumberFormatException nfe )
{
out.println("Middle 7 chars are not DIGITS.");
}
}
else
{
out.println("First Name and Last Name should not contain salutations or special characters.");
}
}
else
{
out.println("Mandatory fields should not be empty.");
}
}
%>

Reply With Quote
  #19  
Old September 27th, 2002, 04:06 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks a million, pal.

Reply With Quote
  #20  
Old September 27th, 2002, 04:11 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Can you do me a favor and post those in code blocks so the indentation is preserved? (You can just go back and edit your posts. Put [!CODE] in front and [!/CODE] after. Remove the !'s, first, though ).

** edit **
Actually, you've got some really long lines there. Better would be to upload the files. You can attach files to a message (button below the input box). Would make it much easier on me hehe.

Reply With Quote
  #21  
Old September 27th, 2002, 04:27 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here are the files..

Reply With Quote
  #22  
Old September 27th, 2002, 03:27 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Well, I'm kinda confused now It looks like the code you posted should work...

What *exactly* is it supposed to be doing that isn't working right?

Keep in mind that I can't test it since I don't have your database connection

Reply With Quote
  #23  
Old September 29th, 2002, 07:25 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the bin and binte check isn't working..

Reply With Quote
  #24  
Old September 29th, 2002, 09:30 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Your logic looks right, so I'm not sure...

Here's a different way to go about checking strings. See if you can apply it to what you've got and make it work

Reply With Quote
  #25  
Old September 30th, 2002, 07:30 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks.. after some modifications it finally works..

Reply With Quote
  #26  
Old September 30th, 2002, 07:34 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Good deal

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > check a string to see if it contains a specific word


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP