Tokens.countTokens().... Help
Hi All,
Can anyone out there tell me why my tokens.countTokens() doesn't work? It returns 0 with the while loop in place and a 4 when I comment out the while loop. I need for the tokenCount to happen after the while loop. Any ideas would be a greatly appreciated.
StringTokenizer tokens = new StringTokenizer("token count doesn't work");
while (tokens.hasMoreTokens()){
tmp = tokens.nextToken();
output += tmp.charAt(0) + " ";
} // end while
// get the number of words
output += "\no Number of words: " + tokens.countTokens();Thanks,
Karl
Try reading the API documentation. The API documentation for StingTokenizer.countTokens states:
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.
Since you have already exhausted all the tokens when you call this method, of course it will return 0. If you want the count of tokens before you start grabbing tokens, then just save the token count to a variable before the loop:
int tokenCount = tokens.countTokens();
while (tokens.hasMoreTokens()){
tmp = tokens.nextToken();
output += tmp.charAt(0) + " ";
} // end while
// get the number of words
output += "\no Number of words: " + tokenCount;
Similar Messages
-
I bought some tokens to help on 'Words with friends' but they didn't download. I have the receipt for the purchase. How can I collect the tokens?
You will never receive a reply from Physios because they have discontinued the game and all support for it.
-
When using the tokenizer in Java I see that you can count tokens "countTokens() " , see if a string has more tokens "hasMoreTokens()", etc. But how do you work with the current token?
For example:
while ((str = in.readLine()) != null )
StringTokenizer tokens = new StringTokenizer(str);
while (tokens.hasMoreTokens())
System.out.println( tokens.nextToken() + "\n" );
//tokenStr = tokens.nextToken();
count++;
//if (tokenStr.equals("<body>"))
// bodycount++;
}I can count all the tokens in the string but how can I count the tokens "<body>"?
Any help please
eddiemjmYou are almost there. Trywhile ((str = in.readLine()) != null )
StringTokenizer tokens = new StringTokenizer(str);
while (tokens.hasMoreTokens())
tokenStr = tokens.nextToken();
System.out.println( tokenStr + "\n" );
count++;
if (tokenStr.equals("<body>"))
bodycount++;
}Note the change and move of the println() call. -
hey all im a first time poster and a first year IT student so sorry if this is old hat but i need a hand.
Im using a standard Tokenizer...in a GUI .
I have it that the program prints each token (word or whatever) on a seperate line to each other in the output field.........but what i need as well, is to count the amount of tokens in the same output field as well or a different one (dose not bother me).....any ideas would be VERY apprieciated.
This is not an ssignment but just an exercise hand in.
Here is my code so you can see what im on about.
Thanks for your help
Armatige
---------------=================---------------------------
public void buttonClicked( JButton theButton ){
if( theButton == clickMe ){
String inputValue = inputField.getText();
inputField.setText( "" );
output2Field.append( "--> " +
inputValue );
StringTokenizer tokens = new StringTokenizer(inputValue);
while (tokens.hasMoreTokens())
outputField.append( "\n" + tokens.nextToken());
public static void main( String [] args ){
Example01 tpo = new Example01();
tpo.setTitle( "Example01" );
tpo.setSize( 250, 150 );
tpo.setVisible( true );Hi...
Not too sure if I understand your post. Surely you can just use the following method of StringTokenizer to get at what you want?
http://java.sun.com/j2se/1.4/docs/api/java/util/StringTokenizer.html#countTokens()
//your code
StringTokenizer tokens = new StringTokenizer (inputValue);
int numTokens = tokens.countTokens ( )
//some more of your code, doing something with numTokens variable (displaying it perhaps) -
I am in horry please if some one can help me with my FTP code, thanks
import java.io.*;
import java.net.*;
import java.util.*;
public class Ass_2 {
public static void main(String[] args){
String currentPath = new String(); currentPath = "ftp://ftp.scit.wlv.ac.uk/pub";
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str,user,pass ;
System.out.println("\n\nTYPE HELP for view the list of commands and there Formats!!");
System.out.println("enter command 'bye' to exit the application");
System.out.print("Enter Username: ");
user = in.readLine();
System.out.print("Enter Password: ");
pass = in.readLine();
String tempPath = new String();
String toFile = new String();
tempPath = currentPath ;
readPage(currentPath);
while (!(str = in.readLine()).equals("bye")){
int tokencount;
StringTokenizer token = new StringTokenizer(str);
tokencount = token.countTokens();
String block[] = new String[tokencount];
for (int i = 0; i < tokencount; i++)
block[i] = token.nextToken();
System.out.println(block);
if (block[0].equalsIgnoreCase("dir")){
System.out.println("DIR");
System.out.println(currentPath);
readPage(currentPath);
System.out.println("\n");
}else if(block[0].equalsIgnoreCase("cwd")){
System.out.println("Change Directory");
currentPath = changeDirectory(currentPath, block[1]);
System.out.println("\n");
}else if(block[0].equalsIgnoreCase("get")){
System.out.println("Wait Copying File : "+block[1]);
copyFile(currentPath,block[1]);
}else if(block[0].equalsIgnoreCase("cd..")){
currentPath = goBack(currentPath);
}else if(block[0].equalsIgnoreCase("help")){
System.out.println("\nYour in the Help Section \n");
}else {
System.out.println("Wrong Command or Format, Type Help!!!");
System.out.println("\n");
catch(Exception e){
System.out.println(e);
// Function to read content form the specfied path
static void readPage(String path){
String tempPath = new String();
try {
URL pageref = new URL(path);
InputStream in = pageref.openStream();
BufferedReader inline = new BufferedReader(new InputStreamReader(in));//(instr);
String line;
int linect = 0;
while((line = inline.readLine())!=null){
linect++;
System.out.println(line);
System.out.println("lines read = "+linect);
catch(Exception e){
System.out.println(e);
static String changeDirectory(String path,String dir){
path = path+"/"+dir;//System.out.println(">>>>>>>>>>> " path" >>> \n");
readPage(path);
return path;
// Function to go one setp back from the current directory
static String goBack(String currentPath){
return currentPath;
/// Function for basic copy TXT file
static void copyFile(String path,String file){
try {
path = path +"/"+ file; //System.out.println("Copy Path : " + path);
String fileName = new String();
fileName = file+".txt";
System.out.println("Out put file name : " + fileName);
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(fileName));
URL pageref = new URL(path);
InputStream in = pageref.openStream();
BufferedReader inline = new BufferedReader(new InputStreamReader(in));//(instr);
String line;
int linect = 0;
while((line = inline.readLine())!=null){
System.out.println(line);
linect++; //System.out.println(line);
out.write(line+"\r\n");
out.close();
System.out.println("File - " file " - copyed Successfully !!");
catch(Exception e){
System.out.println(e);h2. {color:#ff0000}Double post{color}
Replies here:
http://forum.java.sun.com/thread.jspa?threadID=5253627
It's rude to double post.
It's futile (at best) to advertise your time pressure.
It's pointless to use a forum like this but not actually ask a question. -
Help with CIS Lab - Flesch Readability Index
I am a first year computer science student and I need some help with one of our projects. It is working on the Flesch Readibility Index.
We have to create three classes: word, sentence and Flesch (which will include the main method)
The word class has to have the methods countSyllables, getWord and isVowel. We already did that.
The sentence class has to have methods countWords, and nextWord.
We have countWords but are having a lot of problems with nextWord.
As of right now when we call the nextWord() method from the main method, we are given only the first or last word in the sentence. I'm using a string tokenizer to do this.
I need to somehow figure out how to make the method where when it is called it gives one word, remembers the word it gave and then when called again gives the next word because the method cannot be passed any value. It would be a lot easier if I could pass what word I wanted and then just use an array.
Here is what my partner and I have so far:
import java.util.*;
import java.io.*;
* Write a description of class Sentence here.
* @author (your name)
* @version (a version number or a date)
public class Sentence
String sentence;
private int tokenCount;
public Sentence(String s)
sentence = new String(s);
public int countWords()
int numWords = 0;
boolean prevWhitespace = true;
for (int i = 0; i < sentence.length(); i++)
char c = sentence.charAt(i);
boolean currWhitespace = Character.isWhitespace(c);
if (prevWhitespace && !currWhitespace)
numWords++;
prevWhitespace = currWhitespace;
return numWords;
public Word nextWord()
StringTokenizer tokens = new StringTokenizer(sentence, " .,", false);
Word test = new Word("");
tokenCount = tokens.countTokens();
for (int i = 0; i < tokenCount; i++)
test = new Word(tokens.nextToken());
return test;
public static void main(String[] args)
Sentence test = new Sentence("The quick sly fox jumped over the lazy brown dog.");
System.out.println(test.nextWord().getWord());
System.out.println(test.nextWord().getWord());
System.out.println(test.nextWord().getWord());
System.out.println(test.nextWord().getWord());
System.out.println(test.nextWord().getWord());
}Where the main method gives us:
dog
dog
dog
dog
dogAnother thing is that for nextWord() the return type has to be Word.
Here is a link to the full lab:
http://users.dickinson.edu/~braught/courses/cs132f02/labs/lab07.html
Any help you can give would be GREATLY appreciatedPlease read the teacher's instructions again. All the information that you need to know is in there. They explicitly state: "use a StringTokenizer as part of the the instance data". Read up on what instance data means. Utilize this instruction and it should fall into place.
Edited by: petes1234 on Oct 28, 2007 8:34 AM -
The Security Token Service is not available.
hi,
1. service check failed--
http://localhost:port/SecurityTokenServiceApplication/securitytoken.svc
Gettng Error message
2. while provision it again..
Get-SPServiceApplication | ?{$_ -match "Security"}
$sts.Status (result got -online)
$sts.Provision()
----Successful...
3.Event at Event viewer,..
WebHost failed to process a request.
Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/31626309
Exception: System.Web.HttpException: The service '/SecurityTokenServiceApplication/securitytoken.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/SecurityTokenServiceApplication/securitytoken.svc' does not exist.
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
--- End of inner exception stack trace ---
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
Process Name: w3wp
Process ID: 5752
---------------------And-----------------------------
Event 8306
An exception occurred when trying to issue security token: The requested service, 'http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc'
could not be activated. See the server's diagnostic trace logs for more information..
Please help----------------
Prasad kambarCheck this article
http://blogs.technet.com/b/sykhad-msft/archive/2012/02/25/sharepoint-2010-nailing-the-error-quot-the-security-token-service-is-unavailable-quot.aspx
and similar thread
https://social.technet.microsoft.com/Forums/office/en-US/78cd4366-b11b-4300-93a4-4135d55f561f/error-8306-an-exception-occurred-when-trying-to-issue-security-token-please-help?forum=sharepointgeneralprevious
though it is SharePoint 2010 but will work similar in sps 2013 also -
Can anybody explain me what the tokens are in AMT and how they must be used.
Are tokens only for security on control level ?
And what are the advantages of using these?
Thanks for your help.Hi Wim,
For Business Object level authorization SAP provides a so-called Token which describes how Business Object data can be accessed by the user.
Tokens are used to grant authorization for a particular class of protected Business Object regarding the standard activities read, modify, delete and create new.
Additionally you can assign Authorization Rules to a Token defining the valid scope of a Token, meaning in which scope of a business context the authorization is granted. Authorization Rules are defined based on of the Business Object Fields stored in the Application Repository.
Using Tokens with Authorization Rules offer the feature of value based authorization, meaning authorization changes depending on the values stored in the Business Object itself.
Tokens are stored in a Role which can contain many Tokens regarding many protected Business Objects.
Here is the best place to find info on this topic:
"Defining an Authorization Token"
http://help.sap.com/saphelp_crm50/helpdata/en/cb/7f023c2b6c6608e10000000a11402f/frameset.htm
Regards,
Vadim. -
Wsit: Modify the URL of the security token service at runtime
I've managed to modify the url of my webservice endpoint at runtime used by a client application with the BindingProvider.ENDPOINT_ADDRESS_PROPERTY. Is it also possible to modify the url of the security token service?
Check this article
http://blogs.technet.com/b/sykhad-msft/archive/2012/02/25/sharepoint-2010-nailing-the-error-quot-the-security-token-service-is-unavailable-quot.aspx
and similar thread
https://social.technet.microsoft.com/Forums/office/en-US/78cd4366-b11b-4300-93a4-4135d55f561f/error-8306-an-exception-occurred-when-trying-to-issue-security-token-please-help?forum=sharepointgeneralprevious
though it is SharePoint 2010 but will work similar in sps 2013 also -
Dynamic strings from stringtokenizer..any help please?
basically u hav a jsp search page...and on the page is a textbox where a user can type in information they want to match.
now they hav to type it in a way so that the criteria is separated by 'AND' i.e. search greg AND ching
and this should be taken from the textbox...passed into a process javabean...broken up into separate strings
i.e.
String one = greg
String two = ching
and then i will input this into an sql statement to search the database.
my question is what i have done so far is this...
String searchCriteria = request.getParameter("searchArea");
String target = "";
String nextTarget = "";
StringTokenizer token = new StringTokenizer(searchCriteria,"AND");
while(token.hasMoreTokens()) {
target = token.nextToken();
out.println(target);
which basically gets the data from the textbox...separates the criteria when it sees AND and then saves it in a string called target
so at the moment the String target will be = greg ching
is there anyway i can separate the criteria via AND (like above) and save it in separate String variables rather than just one?
bare in mind that if they enter 3 criteria....like greg AND ching AND struggling then it should make 3 strings and save it in them respectively
thanks a lot...im sure its a minor thing butu see im really really thick :o(Sure... a couple of ways you could do it..
StringTokenizer token = new StringTokenizer(searchCriteria,"AND");
String[] criteria = new String[token.countTokens()];
int j=0;
while(token.hasMoreTokens())
criteria[j] = token.nextToken();
/* OR */
StringTokenizer token = new StringTokenizer(searchCriteria,"AND");
ArrayList criteria = new ArrayList();
while(token.hasMoreTokens())
criteria.add(token.nextToken()); -
using indesign cs2 on a mac: when running the textcleanup script i get an error that says the following: applescript error! error number: -2741 error string: adobe indesign cs2 got an error: expected expression, etc. but found unknown token.
any help would be appreciated! thanks!ah forgive me,
i had to create a new text file, which was formatted off an example from the internet. i am able to run the script and choose which text file i would like to use, after i choose the text file, the error pops up./ -
I think I have got it! (Almost)...Please take a look.
Hi - I am working on a homework assignment for my Java Programming class and I have already gotten some really good advice here. I am trying to create a program that allows me to Encode/Decode Morse Code and display the cipher text or plain text depending.
I have created one base class MorseCode and have two derived classes EncodeApp and DecodeApp to illustrate the core functionality of the MorseCode class.
I have used a variety of methods. Some directly from my own twisted little mind and others after receiving excellent instruction from some of you in this forum. (thanks)
Essentially, I now have a couple of problems that I am having trouble solving.
1. I cannot figure out how to test for the entry of invalid characters in the morse code part. I mean I do not know how to account for "." and "-" as opposed to looking for valid input with Character.isLetterOrDigit() or isWhiteSpace(). Help!
2. I recieved some help earlier and did my research on HashMaps...of course this was very enlightening. So I basically followed the guidelines given by the instructions I received. But since I am an ethical person, and this is for school, I did not copy the code I received earlier. Now of course I have a bug. Essentially, when I use the Decode() method with the following input:
...<1 Space>---<1 Space>...<3 Spaces>...<1 Space>---<1 Space>... (where <Space> means hitting the spacebar on my keyboard) I should get output of SOS SOS but instead I get SOS SSOS...Why?
I have included the code below:
MorseCode.java
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Arrays.*;
import java.lang.Character.*;
public class MorseCode extends Object
//A-Z as elements of char array
public static char arrayAlpha[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z'};
//A-Z in Morse Code Strings (0-25 indexes in alphabetical order)
public static String arrayAlphaMorse [] = {".-", "-...","-.-.","-..",".",
//0-9 as elements of char array
public static char arrayNumb[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
//0-9 in Morse Code Strings (0-9 indexes in numberical order beginning at 0)
public static String arrayNumbMorse [] = {"-----", ".----", "..---", "...--", "....-",
//All of the characters and numbers with corresponding MC as a hashmap
public static HashMap cipherKey = new HashMap();
//String to hold output
private String output = "";
public void Encode ( String s )
char messageArray[];
String messageIn = "";
messageIn = s;
messageArray = messageIn.toCharArray();
for( int i = 0; i < messageArray.length; i++)
if(Character.isLetter(messageArray))
output += arrayAlphaMorse[Arrays.binarySearch(arrayAlpha, messageArray[i])] + " ";
} else
if(Character.isDigit(messageArray[i]))
output += arrayNumbMorse[Arrays.binarySearch(arrayNumb, messageArray[i])] + " ";
} else
if(Character.isWhitespace(messageArray[i]))
output += " ";
} else
if(!(Character.isLetterOrDigit(messageArray[i])) && !(Character.isWhitespace(messageArray[i])))
JOptionPane.showMessageDialog (null, "Unsupported Characters Entered. You may only use letters, numbers and spaces.","Message as Morse Code - System Message", JOptionPane.ERROR_MESSAGE );
}//EndForLoop
}//EOEncode
public void Decode ( String s )
cipherKey.put( ".-", "A" );
cipherKey.put( "-...", "B" );
cipherKey.put( "-.-.", "C" );
cipherKey.put( "-..", "D" );
cipherKey.put( ".", "E" );
cipherKey.put( "..-.", "F" );
cipherKey.put( "--.", "G" );
cipherKey.put( "....", "H" );
cipherKey.put( "..", "I" );
cipherKey.put( ".---", "J" );
cipherKey.put( "-.-", "K" );
cipherKey.put( ".-..", "L" );
cipherKey.put( "--", "M" );
cipherKey.put( "-.", "N" );
cipherKey.put( "---", "O" );
cipherKey.put( ".--.", "P" );
cipherKey.put( "--.-", "Q" );
cipherKey.put( ".-.", "R" );
cipherKey.put( "...", "S" );
cipherKey.put( "-", "T" );
cipherKey.put( "..-", "U" );
cipherKey.put( "...-", "V" );
cipherKey.put( ".--", "W" );
cipherKey.put( "-..-", "X" );
cipherKey.put( "-.--", "Y" );
cipherKey.put( "--..", "Z" );
cipherKey.put( "-----", "0" );
cipherKey.put( ".----", "1" );
cipherKey.put( "..---", "2" );
cipherKey.put( "...--", "3" );
cipherKey.put( "....-", "4" );
cipherKey.put( ".....", "5" );
cipherKey.put( "-....", "6" );
cipherKey.put( "--...", "7" );
cipherKey.put( "---..", "8" );
cipherKey.put( "----.", "9" );
String input ="";
String intermsg = "";
String alphaString = "";
String morseString = "";
String delimiter = "#";
input = s;
StringBuffer buffer = new StringBuffer(input);
Problem is that char cannot be dereferenced??? Need to fix.
for( int i = 0; i < buffer.length()- 1; i++)
if((!(buffer.charAt(i).equals("."))) ||(!(buffer.charAt(i).equals("-"))))
JOptionPane.showMessageDialog (null, "Unsupported Characters Entered. You may only use letters, numbers and spaces.","Morse Code as Text - System Message", JOptionPane.ERROR_MESSAGE);
System.exit(0);
for( int i = 0; i < buffer.length()- 1; i++)
if((Character.isWhitespace(buffer.charAt(i))) && (Character.isWhitespace(buffer.charAt(i + 1))))
buffer.setCharAt(i + 1, '#');
intermsg = buffer.toString();
StringTokenizer tokens = new StringTokenizer( intermsg );
int length = tokens.countTokens();
StringBuffer Output = new StringBuffer((length * 2));
while(tokens.hasMoreTokens())
morseString = tokens.nextToken();
if(morseString.equals(delimiter))
Output.append(" ");
} else
alphaString = (String)cipherKey.get( morseString );
Output.append( alphaString != null ? alphaString : delimiter );
output = Output.toString();
}//EODecode
public String Output()
return output;
}//EOF
EncodeApp.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class EncodeApp extends MorseCode
public static void main(String args[] )
String input ="";
String intermsg = "";
String messageIn = "";
input = JOptionPane.showInputDialog(
"Enter Message to be Converted to Morse Code:");
intermsg = input.trim();
messageIn = intermsg.toUpperCase();
MorseCode e = new MorseCode();
e.Encode(messageIn);
JOptionPane.showMessageDialog (null, e.Output(),
"Message as Morse Code", JOptionPane.INFORMATION_MESSAGE );
System.exit( 0 );
}//EOF
DecodeApp.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class DecodeApp extends MorseCode
public static void main(String args[] )
String input = "";
String messageout = "";
input = JOptionPane.showInputDialog(
"Enter Morse Code to be Converted to Plain Text:");
messageout = input;
MorseCode d = new MorseCode();
d.Decode(messageout);
JOptionPane.showMessageDialog (null, d.Output(),
"Morse Code as Plain Text", JOptionPane.INFORMATION_MESSAGE );
System.exit( 0 );
}//EOF
Thanks for your help!Input only <ONE SPACE> after ... --- ...
code may be taking spaces as input
or hard code a stream of " " to = a space in output -
Hello everyone i am building a database/web page application using Dreamweaver 8 that allows sudents to report computer issues. The submitting works fine it stores all information to the databse my problem now is updating the database to show a problem has been fixed. I can get the website to pull up current records using but when i click on the lik that should redirect the user to the update form which pulls up the record that the user clicked on i get this error:
exception
org.apache.jasper.JasperException: Exception in JSP: /updateIssue.jsp:151
148: <table align="center">
149: <tr valign="baseline">
150: <td nowrap align="right">Cpu:</td>
151: <td><input type="text" name="cpu" value="<%=(((IssueUpdate_data = IssueUpdate.getObject("cpu"))==null || IssueUpdate.wasNull())?"":IssueUpdate_data)%>" size="32">
152: </td>
153: </tr>
154: <tr valign="baseline">
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Invalid cursor state
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.updateIssue_jsp._jspService(updateIssue_jsp.java:284)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getObject(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getObject(Unknown Source)
org.apache.jsp.updateIssue_jsp._jspService(updateIssue_jsp.java:226)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
My code for the page is:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<%@ include file="Connections/db.jsp" %>
<%
// *** Edit Operations: declare variables
// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
String queryString = request.getQueryString();
String tempStr = "";
for (int i=0; i < queryString.length(); i++) {
if (queryString.charAt(i) == '<') tempStr = tempStr + "<";
else if (queryString.charAt(i) == '>') tempStr = tempStr + ">";
else if (queryString.charAt(i) == '"') tempStr = tempStr + """;
else tempStr = tempStr + queryString.charAt(i);
MM_editAction += "?" + tempStr;
// connection information
String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;
// redirect information
String MM_editRedirectUrl = null;
// query string to execute
StringBuffer MM_editQuery = null;
// boolean to abort record edit
boolean MM_abortEdit = false;
// table information
String MM_editTable = null, MM_editColumn = null, MM_recordId = null;
// form field information
String[] MM_fields = null, MM_columns = null;
%>
<%
// *** Update Record: set variables
if (request.getParameter("MM_update") != null &&
request.getParameter("MM_update").toString().equals("form1") &&
request.getParameter("MM_recordId") != null) {
MM_editDriver = MM_db_DRIVER;
MM_editConnection = MM_db_STRING;
MM_editUserName = MM_db_USERNAME;
MM_editPassword = MM_db_PASSWORD;
MM_editTable = "issue";
MM_editColumn = "cpu";
MM_recordId = "'" + request.getParameter("MM_recordId") + "'";
MM_editRedirectUrl = "COBA_home.html";
String MM_fieldsStr = "cpu|value|issue|value|comment|value|issue_Date|value|Fixed|value";
String MM_columnsStr = "cpu|',none,''|issue|',none,''|comment|',none,''|issue_Date|',none,''|Fixed|',none,''";
// create the MM_fields and MM_columns arrays
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|");
MM_fields = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken();
tokens = new java.util.StringTokenizer(MM_columnsStr,"|");
MM_columns = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken();
// set the form values
for (int i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = ((request.getParameter(MM_fields)!=null)?(String)request.getParameter(MM_fields[i]):"");
// append the query string to the redirect URL
if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
%>
<%
// *** Update Record: construct a sql update statement and execute it
if (request.getParameter("MM_update") != null &&
request.getParameter("MM_recordId") != null) {
// create the update sql statement
MM_editQuery = new StringBuffer("update ").append(MM_editTable).append(" set ");
for (int i=0; i+1 < MM_fields.length; i+=2) {
String formVal = MM_fields[i+1];
String elem;
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],",");
String delim = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String altVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
if (formVal.length() == 0) {
formVal = emptyVal;
} else {
if (altVal.length() != 0) {
formVal = altVal;
} else if (delim.compareTo("'") == 0) { // escape quotes
StringBuffer escQuotes = new StringBuffer(formVal);
for (int j=0; j < escQuotes.length(); j++)
if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\'');
formVal = "'" + escQuotes + "'";
} else {
formVal = delim + formVal + delim;
MM_editQuery.append((i!=0)?",":"").append(MM_columns[i]).append(" = ").append(formVal);
MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId);
if (!MM_abortEdit) {
// finish the sql and execute it
Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
MM_editStatement.executeUpdate();
MM_connection.close();
// redirect with URL parameters
if (MM_editRedirectUrl.length() != 0) {
response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
return;
%>
<%
String IssueUpdate__MMColParam = "1";
if (request.getParameter("cpu") !=null) {IssueUpdate__MMColParam = (String)request.getParameter("cpu");}
%>
<%
Driver DriverIssueUpdate = (Driver)Class.forName(MM_db_DRIVER).newInstance();
Connection ConnIssueUpdate = DriverManager.getConnection(MM_db_STRING,MM_db_USERNAME,MM_db_PASSWORD);
PreparedStatement StatementIssueUpdate = ConnIssueUpdate.prepareStatement("SELECT * FROM issue WHERE cpu = '" + IssueUpdate__MMColParam + "' ORDER BY Fixed ASC");
ResultSet IssueUpdate = StatementIssueUpdate.executeQuery();
boolean IssueUpdate_isEmpty = !IssueUpdate.next();
boolean IssueUpdate_hasData = !IssueUpdate_isEmpty;
Object IssueUpdate_data;
int IssueUpdate_numRows = 0;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" action="<%=MM_editAction%>" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Cpu:</td>
<td><input type="text" name="cpu" value="<%=(((IssueUpdate_data = IssueUpdate.getObject("cpu"))==null || IssueUpdate.wasNull())?"":IssueUpdate_data)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Issue:</td>
<td><input type="text" name="issue" value="<%=(((IssueUpdate_data = IssueUpdate.getObject("issue"))==null || IssueUpdate.wasNull())?"":IssueUpdate_data)%>" size="32">
</td>
</tr>
<tr>
<td nowrap align="right" valign="top">Comment:</td>
<td valign="baseline"><textarea name="comment" cols="50" rows="5"><%=(((IssueUpdate_data = IssueUpdate.getObject("comment"))==null || IssueUpdate.wasNull())?"":IssueUpdate_data)%></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Issue_Date:</td>
<td><input type="text" name="issue_Date" value="<%=(((IssueUpdate_data = IssueUpdate.getObject("issue_Date"))==null || IssueUpdate.wasNull())?"":IssueUpdate_data)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Fixed:</td>
<td><input type="text" name="Fixed" value="<%=(((IssueUpdate_data = IssueUpdate.getObject("Fixed"))==null || IssueUpdate.wasNull())?"":IssueUpdate_data)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record">
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=(((IssueUpdate_data = IssueUpdate.getObject("cpu"))==null || IssueUpdate.wasNull())?"":IssueUpdate_data)%>">
</form>
<p> </p>
</body>
</html>
<%
IssueUpdate.close();
StatementIssueUpdate.close();
ConnIssueUpdate.close();
%>
Any idea as to what I have done wrong because I am very confused right now. Thank you so much in advance for any help or adviceI am confused as well.
It would help if your data layer was separate from your display layer.
The error suggests that you are attempting to extract a result from a update. And that won't work with a standard update.
Where that is happening I have no idea. -
Problem to read and write files on hdd out of html with an Applet ????
hi there,
i wrote an applet for loading a file from HDD or saving data out of a cookie in a file on a hdd.
when i compile the class there are warnings about "unchecked method invocation" and "unchecked conversion".
what did i do wrong?
i think it's about this function:
AccessController.doPrivileged(new PrivilegedAction()
public Object run()
if(saveCartAtOnce.toLowerCase().compareTo("true")== 0)
SaveShoppingCart();
}//if
return null;
}// public Object run
});//AccessController
could anyone help me?
i could also send the whole class then....
thanks a lot.
greetings
Volker Becht
[email protected]OK
now i will post the whole class.
my questen is: what have i to do so that anything runs?
if anyone will need a file example which should be read
into the calss i will email it.
package de.CATALOGcreator.shoppingcart;
import java.awt.*;
import java.io.*;
import java.applet.*;
import java.util.*;
import java.security.*;
import netscape.javascript.*;
public class shoppingcart extends java.applet.Applet
private static final long serialVersionUID = 1234567890L;
//Explanation of the possible Parameters of the applet, all of the following
//parameters need not be given explicitely, because they have default values.
String errorMessageInvalidFileFormat = ""; //set the ErrorMessage String for InvalidFileFormat when loading
String openDialogTitle = ""; //set the Open Dialog Title
String saveDialogTitle = ""; //set the Save Dialog Title
String articleNumberString = ""; //set the ArticleNumber of the CSV headline
String articleNameString = ""; //set the ArticleName of the CSV headline
String amountString = ""; //set the AmountName of the CSV headline
String priceString = ""; //set the PriceName of the CSV headline
String delimiterString =""; //set the Delimiter for the Output-csv
String inputdelimiterString =""; //set the Delimiter for the Intput-csv
//No parameter, this String is built from articleNumberString, articleNameString, amountString and
//priceString and delimiterString in the following manner:
//headline = articleNumberString + delimiterString + articleNameString + delimiterString + amountString+ delimiterString + priceString;
//see: init();
String headline = ""; //set the Headline of the csv-file
//Another parameter is saveCartAtOnce, which says, if the save-Dialog is schown
//at once when the applet is initialized. If the value is "true", the dialog shows
//at once, in all other cases (also if parameter does not exist) you have to
//call SaveShoppingCart explicitely.
String saveCartAtOnce;
public void init()
try
//set the default setting for the Paramters
openDialogTitle = this.getParam("openDialogTitle", "Open Shopping Cart");
saveDialogTitle = this.getParam("saveDialogTitle", "Save File As");
errorMessageInvalidFileFormat = this.getParam("errorMessageInvalidFileFormat", "Invalid File Format!\nLoading stopped.");
delimiterString = this.getParam("delimiterString", "||");
inputdelimiterString= this.getParam("inputdelimiterString", ",");
articleNumberString = this.getParam("articleNumberString", "Article Number");
articleNameString = this.getParam("articleNameString", "Article");
amountString = this.getParam("amountString", "Amount");
priceString = this.getParam("priceString", "Price");
headline = articleNumberString + delimiterString + articleNameString + delimiterString + amountString + delimiterString + priceString;
saveCartAtOnce = this.getParameter("saveCartAtOnce");
AccessController.doPrivileged(new PrivilegedAction()
public Object run()
if(saveCartAtOnce.toLowerCase().compareTo("true")== 0)
SaveShoppingCart();
//LoadShoppingCart();
}//if
return null;
}// public Object run
});//AccessController
catch(Exception e)
e.printStackTrace();
}//void init
public void SaveShoppingCart()
DataOutputStream dos;
String myFile;
File f ;
myFile = SaveDialog();
if(myFile!=null)
f = new File(myFile);
String Artikel=getParameter("Artikel");
String Anzahl=getParameter("MyAnzahl");
String Bezeichnung=getParameter("Bezeichnung");
String Preis=getParameter("Preis");
StringTokenizer stArticle = new StringTokenizer(Artikel, inputdelimiterString);
StringTokenizer stAnzahl = new StringTokenizer(Anzahl, inputdelimiterString);
StringTokenizer stBezeichnung = new StringTokenizer(Bezeichnung, inputdelimiterString);
StringTokenizer stPreis = new StringTokenizer(Preis, inputdelimiterString);
JSObject.getWindow(this).eval("alert('"+ Artikel +"')");
try
dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
// Line 1
dos.writeChars(headline + "\n");
while (stArticle.hasMoreTokens())
String tmpArticle=stArticle.nextToken();
String tmpAnzahl=stAnzahl.nextToken();
String tmpBezeichnung=stBezeichnung.nextToken();
String tmpPreis=stPreis.nextToken();
dos.writeChars(tmpArticle + delimiterString + tmpBezeichnung + delimiterString +tmpPreis + delimiterString + tmpAnzahl + "\n");
}//while
dos.flush();
System.out.println("Successfully wrote to the file named " + myFile + " -- go take a look at it!");
dos.close();
}//try
catch (SecurityException e)
System.out.println("JavaSoft SaveShoppingCart: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
e.printStackTrace(System.out);
}//catch
catch (IOException ioe)
System.out.println("JavaSoft SaveShoppingCart: IOexception\nMessage:" + ioe.getMessage() + "\nStackTrace:");
ioe.printStackTrace(System.out);
}//catch
}//if
}//void SaveShoppingCart
private String SaveDialog()
try
//Date now = new Date(System.currentTimeMillis());
Calendar rightNow = Calendar.getInstance();
//SystemDate
//String strDay = Integer.toString(now.getDate());
String strDay = Integer.toString(rightNow.get(Calendar.DAY_OF_MONTH));
//String strMonth = Integer.toString(now.getMonth()+1);
String strMonth = Integer.toString(rightNow.get(Calendar.MONTH));
//String strYear = Integer.toString(now.getYear()+1900);
String strYear = Integer.toString(rightNow.get(Calendar.YEAR));
//SystemTime
//String strHoure = Integer.toString(now.getHours());
String strHoure = Integer.toString(rightNow.get(Calendar.HOUR));
//String strMinutes = Integer.toString(now.getMinutes());
String strMinutes = Integer.toString(rightNow.get(Calendar.MINUTE));
//String strSeconds = Integer.toString(now.getSeconds());
String strSeconds = Integer.toString(rightNow.get(Calendar.SECOND));
//set SystemDate+SystemTime
String strDate=strDay+"_"+strMonth+"_"+strYear+"_"+strHoure+"_"+strMinutes+"_"+strSeconds;
//set SaveName as *.csv
String SaveAs = strDate + ".csv";
FileDialog fd = new FileDialog (new Frame(), "Save File As", FileDialog.SAVE);
fd.setFile(SaveAs);
fd.setVisible(true);
//Value Save or Cancel Button
if((fd.getDirectory() == null) || (fd.getFile() == null)) // user pressed the cancel - button
return null;
}//if
else // user pressed save - button
return fd.getDirectory() + fd.getFile();
}//else
}//try
catch (SecurityException e)
System.out.println("JavaSoft String SaveDialog: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
e.printStackTrace(System.out);
return null;
}//catch
}// String SaveDialog
public String OpenDialog()
FileDialog fd = new FileDialog (new Frame(), openDialogTitle, FileDialog.LOAD);
fd.setVisible(true);
return fd.getDirectory() + fd.getFile();
}//String OpenDialog
private String getParam( String paramName, String defaultValue )
String value = getParameter( paramName );
if ( value != null )
return value;
}//if
return defaultValue;
}//String getParam
public void LoadShoppingCart()
String myFile;
File f ;
myFile = OpenDialog();
if(myFile!=null)
f = new File(myFile);
String rl = "";
Object[] Obj = new Object[2];
try
DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(myFile),128));
// Line 1
String FirstLine = myReadLine(dis);
JSObject.getWindow(this).eval("alert('"+ FirstLine +"')");
if(FirstLine.startsWith(headline))
while ( (rl = myReadLine(dis)) != null)
//examines correct delimiter
StringTokenizer token = new StringTokenizer (rl, delimiterString);
if(token.countTokens()!= 4)
dis.close();
JSObject.getWindow(this).eval("alert('"+ errorMessageInvalidFileFormat +"')");
}//if
Obj[0]= (Object)rl;
Obj[1]= (Object)delimiterString;
JSObject.getWindow(this).call("addCSVArticle",Obj); // this=applet
}//while
JSObject.getWindow(this).call("importFinished",null);
else
dis.close();
JSObject.getWindow(this).eval("alert('"+ errorMessageInvalidFileFormat +"')");
//System.exit(-1);
}//else
dis.close();
}//try
catch (SecurityException e)
System.out.println("JavaSoft LoadShoppingCart: SecurityException\nMessage:" + e.getMessage() + "\nStackTrace:");
e.printStackTrace(System.out);
}//catch
catch (IOException ioe)
System.out.println("JavaSoft LoadShoppingCart: IOexception\nMessage:" + ioe.getMessage() + "\nStackTrace:");
ioe.printStackTrace(System.out);
}//catch
catch(Exception exc)
System.out.println("JavaSoft LoadShoppingCart: Exception\nMessage:" + exc.getMessage() + "\nStackTrace:");
exc.printStackTrace(System.out);
}//catch
}//if
}//void LoadShoppingCart
private String myReadLine(DataInputStream dis)
char tmp;
String line = "";
try
while((tmp = dis.readChar())!= '\n')
line += tmp;
return line;
}//try
catch(IOException ioexc)
return null;
}//catch
}//String myReadLine
public boolean isInitialized()
return true;
}//public class ShoppingCart extends java.applet.Applet[/i] -
Quotes in java ser pages and SQL
I am french.
Thursday, April 04, 2002 8:02 PM
Hi all,
I have a memo field in Ultradev (and some text fields) that are inserted into an Filemaker database when the form is submitted.... nothing too exciting, but, i now have to be able to have apostrophes in the text & memo fields. When i have an apostrophe in the field, my application Server (JRUN 3.1) an error occurs - the apostrophe indicates the end of the string to submit to the database. When i don't print apostrophes in the text field, everything is ok.
Please try to help me as soon as possible
Thanks, Arnaud
It is urgent .
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%
// *** Logout the current user.
String MM_Logout = request.getRequestURI() + "?MM_Logoutnow=1";
if (request.getParameter("MM_Logoutnow") != null && request.getParameter("MM_Logoutnow").equals("1")) {
session.putValue("MM_Username", "");
session.putValue("MM_UserAuthorization", "");
String MM_logoutRedirectPage = "../index.jsp";
// redirect with URL parameters (remove the "MM_Logoutnow" query param).
if (MM_logoutRedirectPage.equals("")) MM_logoutRedirectPage = request.getRequestURI();
if (MM_logoutRedirectPage.indexOf("?") == -1 && request.getQueryString() != null) {
String MM_newQS = request.getQueryString();
String URsearch = "MM_Logoutnow=1";
int URStart = MM_newQS.indexOf(URsearch);
if (URStart >= 0) {
MM_newQS = MM_newQS.substring(0,URStart) + MM_newQS.substring(URStart + URsearch.length());
if (MM_newQS.length() > 0) MM_logoutRedirectPage += "?" + MM_newQS;
response.sendRedirect(response.encodeRedirectURL(MM_logoutRedirectPage));
%>
<%@ include file="../Connections/webpaf.jsp" %>
<%
// *** Edit Operations: declare variables
// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
MM_editAction += "?" + request.getQueryString();
// connection information
String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;
// redirect information
String MM_editRedirectUrl = null;
// query string to execute
StringBuffer MM_editQuery = null;
// boolean to abort record edit
boolean MM_abortEdit = false;
// table information
String MM_editTable = null, MM_editColumn = null, MM_recordId = null;
// form field information
String[] MM_fields = null, MM_columns = null;
%>
<%
// *** Update Record: set variables
if (request.getParameter("MM_update") != null &&
request.getParameter("MM_recordId") != null) {
MM_editDriver = MM_webpaf_DRIVER;
MM_editConnection = MM_webpaf_STRING;
MM_editUserName = MM_webpaf_USERNAME;
MM_editPassword = MM_webpaf_PASSWORD;
MM_editTable = "modules";
MM_editColumn = "a_code_module_paf";
MM_recordId = "'" + request.getParameter("MM_recordId") + "'";
MM_editRedirectUrl = "merci_maj.jsp";
String MM_fieldsStr = "titre_dispositif|value|a_titre_module|value|a_public|value|a_objectif|value|a_contenu|value|a_methode|value|lieu_stable|value|a_observation|value";
String MM_columnsStr = "titre_dispositif|',none,''|a_titre_module|',none,''|a_public|',none,''|a_objectif|',none,''|a_contenu|',none,''|a_methode|',none,''|lieu_stable|',none,''|a_observation|',none,''";
// create the MM_fields and MM_columns arrays
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|");
MM_fields = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken();
tokens = new java.util.StringTokenizer(MM_columnsStr,"|");
MM_columns = new String[tokens.countTokens()];
for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken();
// set the form values
for (int i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = ((request.getParameter(MM_fields)!=null)?(String)request.getParameter(MM_fields[i]):"");
// append the query string to the redirect URL
if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
%>
<%
// *** Update Record: construct a sql update statement and execute it
if (request.getParameter("MM_update") != null &&
request.getParameter("MM_recordId") != null) {
// create the update sql statement
MM_editQuery = new StringBuffer("update ").append(MM_editTable).append(" set ");
for (int i=0; i+1 < MM_fields.length; i+=2) {
String formVal = MM_fields[i+1];
String elem;
java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],",");
String delim = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String altVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
if (formVal.length() == 0) {
formVal = emptyVal;
} else {
if (altVal.length() != 0) {
formVal = altVal;
} else if (delim.compareTo("'") == 0) { // escape quotes
StringBuffer escQuotes = new StringBuffer(formVal);
for (int j=0; j < escQuotes.length(); j++)
if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\'');
formVal = "'" + escQuotes + "'";
} else {
formVal = delim + formVal + delim;
MM_editQuery.append((i!=0)?",":"").append(MM_columns[i]).append(" = ").append(formVal);
MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId);
if (!MM_abortEdit) {
// finish the sql and execute it
Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
MM_editStatement.executeUpdate();
MM_connection.close();
// redirect with URL parameters
if (MM_editRedirectUrl.length() != 0) {
response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
%>
<%
String modules__MMColParam = "1";
if (request.getParameter("choix") !=null) {modules__MMColParam = (String)request.getParameter("choix");}
%>
<%
Driver Drivermodules = (Driver)Class.forName(MM_webpaf_DRIVER).newInstance();
Connection Connmodules = DriverManager.getConnection(MM_webpaf_STRING,MM_webpaf_USERNAME,MM_webpaf_PASSWORD);
PreparedStatement Statementmodules = Connmodules.prepareStatement("SELECT a_contenu, a_public, a_observation, a_methode, a_objectif, a_code_module_paf, a_chapitres_clair, a_titre_module, lieu_stable, a_affiche_modalites, a_affiche_type_module_texte_clair, titre_dispositif FROM modules WHERE a_code_module_paf = '" + modules__MMColParam + "' ORDER BY a_code_module_paf ASC");
ResultSet modules = Statementmodules.executeQuery();
boolean modules_isEmpty = !modules.next();
boolean modules_hasData = !modules_isEmpty;
Object modules_data;
int modules_numRows = 0;
%>
<html><!-- #BeginTemplate "/Templates/mod_indenti.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->
<title>Plan académique de formation 2002/2003 de l'Académie de Créteil</title>
<!-- #EndEditable -->
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta NAME="Author" CONTENT="Cellule Acad�mique de Formation de l'Acad�mie de Cr�t�il">
<meta NAME="Keywords" CONTENT="stages, dispositifs, modules, formation, apprentissage, tice, p�dagogie, enseignement,professeurs, lyc�e, coll�ge, �cole, pr�paration au concours, agr�gation">
<meta NAME="Description" CONTENT="Listes des dispositifs et modules du plan acad�mique de formation de l'acad�mie de Cr�teil">
<meta NAME="GENERATOR" content="Macromedia dreamweaver Ultradev4">
<META NAME=Robots CONTENT=All>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../css/couleurs.css" type="text/css">
<script language="JavaScript">
<!--
function addToFavorite(favTitle){
if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) {
window.external.AddFavorite(location.href, unescape(favTitle));
//-->
</script>
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
MM_reloadPage(true);
// -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" width="710">
<!-- fwtable fwsrc="bandeau.png" fwbase="bandeau.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
<tr>
<td width="710">
<table border="0" cellpadding="0" cellspacing="0" width="700">
<!-- fwtable fwsrc="bandeau.png" fwbase="bandeau.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
<tr>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="151" height="1" border="0" name="undefined_2"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="131" height="1" border="0" name="undefined_2"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="287" height="1" border="0" name="undefined_2"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="131" height="1" border="0" name="undefined_2"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="1" height="1" border="0" name="undefined_2"></td>
</tr>
<tr>
<td rowspan="4"><img name="bandeau_r1_c1" src="../Templates/bandeau_caf/bandeau_r1_c1.gif" width="151" height="95" border="0"></td>
<td colspan="3"><img name="bandeau_r1_c2" src="../Templates/bandeau_caf/bandeau_r1_c2.gif" width="549" height="6" border="0"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="1" height="6" border="0" name="undefined_2"></td>
</tr>
<tr>
<td rowspan="2"><img name="bandeau_r2_c2" src="../Templates/bandeau_caf/bandeau_r2_c2.gif" width="131" height="57" border="0"></td>
<td><img name="bandeau_r2_c3" src="../Templates/bandeau_caf/bandeau_r2_c3.gif" width="287" height="51" border="0"></td>
<td rowspan="2"><img name="bandeau_r2_c4" src="../Templates/bandeau_caf/bandeau_r2_c4.gif" width="131" height="57" border="0"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="1" height="51" border="0" name="undefined_2"></td>
</tr>
<tr>
<td><img name="bandeau_r3_c3" src="../Templates/bandeau_caf/bandeau_r3_c3.gif" width="287" height="6" border="0"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="1" height="6" border="0" name="undefined_2"></td>
</tr>
<tr>
<td colspan="3"><img name="bandeau_r4_c2" src="../Templates/bandeau_caf/bandeau_r4_c2.gif" width="549" height="32" border="0"></td>
<td><img src="../Templates/bandeau_caf/spacer.gif" width="1" height="32" border="0" name="undefined_2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="711" border="0" cellpadding="0" cellspacing="0" height="900">
<tr>
<td width="712" height="856" valign="top" bgcolor="#FFFFFF"><!-- #BeginEditable "principal" -->
<p> </p>
<p><font face="Verdana, Arial, Helvetica, sans-serif" color="#000099" size="4"><b><img src="../images/p_orange30.gif" width="30" height="30" align="absmiddle">
Modification d'un enregistrement dans la base de données (suite)</b></font></p>
<p align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"><a href="<%=MM_Logout%>"><b>Quitter
sans faire de modifications</b></a></font></p>
<ul>
<li><b>Vous êtes dans le module </b>: <b><font size="4" face="Verdana, Arial, Helvetica, sans-serif" color="#FF0000"><%= (((modules_data = modules.getObject("a_code_module_paf"))==null || modules.wasNull())?"":modules_data).toString().toUpperCase() %></font></b><br>
<br>
</li>
<li><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Effectuez
vos modifications dans les champs et cliquez sur "mettre à
jour l'enregistrement" :</font></b></li>
</ul>
<form name="maj" method="POST" action="<%=MM_editAction%>">
<p> <b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099"><br>
</font></b></p>
<table width="75%" border="0" cellspacing="0" cellpadding="3" bgcolor="#CCCCCC">
<tr>
<td>
<p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">Titre
dispositif :</font><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#FF0000">
</font></b> <br>
<input type="text" name="titre_dispositif" size="100" value="<%=((((modules_data = modules.getObject("titre_dispositif"))==null || modules.wasNull())?"":modules_data))%>">
</p>
<p> <b><font size="3" face="Verdana, Arial, Helvetica, sans-serif" color="#000099">Titre
module :<br>
</font> </b>
<input type="text" name="a_titre_module" size="100" value="<%=((((modules_data = modules.getObject("a_titre_module"))==null || modules.wasNull())?"":modules_data))%>">
</p>
<p> <b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">Public
</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">
:<br>
</font></b>
<textarea name="a_public" wrap="PHYSICAL" rows="3" cols="70"><%=(((modules_data = modules.getObject("a_public"))==null || modules.wasNull())?"":modules_data)%></textarea>
</p>
<p> <b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">Objectifs
</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">
:</font></b> <br>
<textarea name="a_objectif" cols="70" rows="5"><%=(((modules_data = modules.getObject("a_objectif"))==null || modules.wasNull())?"":modules_data)%></textarea>
</p>
<p> <b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">Contenus
: </font></b> <br>
<textarea name="a_contenu" cols="70" rows="5"><%=(((modules_data = modules.getObject("a_contenu"))==null || modules.wasNull())?"":modules_data)%></textarea>
</p>
<p> <b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">Méthode
:<br>
</font> </b>
<textarea name="a_methode" cols="70" rows="5"><%=(((modules_data = modules.getObject("a_methode"))==null || modules.wasNull())?"":modules_data)%></textarea>
</p>
<p> <b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">Lieu
:</font></b> <br>
<textarea name="lieu_stable" cols="70" rows="3"><%=(((modules_data = modules.getObject("lieu_stable"))==null || modules.wasNull())?"":modules_data)%></textarea>
</p>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099"><b>Observations
:<br>
<textarea name="a_observation" cols="70" rows="3"><%=(((modules_data = modules.getObject("a_observation"))==null || modules.wasNull())?"":modules_data)%></textarea>
</b></font></p>
<p align="center">
<input type="submit" name="Submit" value="Mettre à jour l'enregistrement">
</p>
</td>
</tr>
</table>
<p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="3" color="#000099">
</font></b></p>
<input type="hidden" name="MM_update" value="true">
<input type="hidden" name="MM_recordId" value="<%=(((modules_data = modules.getObject("a_code_module_paf"))==null || modules.wasNull())?"":modules_data)%>">
</form>
<p align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"><a href="<%=MM_Logout%>"><b>Quitter
sans faire de modifications</b></a></font></p>
<p> </p>
<!-- #EndEditable --></td>
<td width="1" height="856"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="middle" bordercolor="#FF8516" colspan="2">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"
color=#999999><font size="2">� Formation des personnels- CRETEIL -
<!-- #BeginDate format:Sw1 -->14 mai, 2002<!-- #EndDate -->
</font></font></div>
</td>
</tr>
<tr>
<td height="2" width="712" bgcolor="#FFFFCC"></td>
<td width="1" height="2"></td>
</tr>
</table>
</body>
<!-- #EndTemplate --></html>
<%
modules.close();
Connmodules.close();
%>If you replace all instances of your apostophe with a double apostrophe (not a quotation, but two apostrophe's), then that serves an escape sequence for most databases.
Maybe you are looking for
-
Hi, I am in the process of migrating from Outlook Express 6 to Thunderbird. Thunderbird made the migration very easy, a click of an "Outlook Express" radio box selection for import. But then I made it hard on myself by deciding I wanted to fix an OE
-
How do I find out the encoding used to import music?
I want to be sure that all of my music is imported using apple lossless encoding. Can I tell from the file somehow or do I have to re-import everything? thanks
-
Problem with Usage Dependencies
Hello, we have a Web Dynpro Application (Migrating from 6.40 to 7.00) which uses Collaboration API: kmc.util.core_api.jar, coll.shared.roomobject_api.jar, coll.shared.types_api.jar and coll.shared.extension_api.jar. I found in SLD the SC KMC COLLABO
-
I built a number of webpages in CS5. CS6 will not open them. When I try to open them, I get a number of error messages. The first one says While executing onLoad in Overlay.CSSgrads_LayoutDiv Manipulator_OnOpen.htm, the followingJavascrpt error oc
-
NOTEBOOK STANTDARD OPERATING TEMPERATURES
IS THESE TEMPERATURE OK AT IDLE STATE CPU 46 °C (115 °F) CPU Package 45 °C (113 °F) CPU IA Cores 45 °C (113 °F) CPU GT Cores 45 °C (113 °F) CPU #1 / Core #1 45 °C (113 °F) CPU #1 / Core #2 44 °C (111 °F) TOSHIBA MQ01ABD075 36 °C (97 °F) Product name: