Download files...Very Urgent!!!!!!!
Hi All,
I want to download same HTML files from the web using Java.
u = new URL("http://www.insproplus.com/press.htm");
URLConnection uc = u.openConnection();
BufferedReader in = new java.io.BufferedReader(new InputStreamReader(u.openStream()));
String rec = null;
while ((rec = in.readLine()) != null)
html += rec;
in.close();
This one is throwing the IOInterruptExpection: timeout exccetion no further information.
My program is Application. not Applet.
Can you give some suggestion and ideas how to download files(HTML pages) from the net?
Best Regards,
Muthu
Hi,
I found the solution for the exception.
we must have set the proxy host on our networkt.
UNIX
java -Dhttp.proxyHost=proxyhost
[-Dhttp.proxyPort=portNumber] runableClassName
DOS shell (Windows 95/NT)
java -Dhttp.proxyHost=proxyhost
[-Dhttp.proxyPort=portNumber] runableClassName
Muthu
Similar Messages
-
Communication b/w SAP and VB .exe file - Very urgent.
hi,
I am currently in a project implementing SAP for a cement manufacturing company. Here we have a VB .exe file which takes parameters and return values. now we need to connect this to application to SAP R/3 to pass data to that application and access the data from that .exe file.
Note: we don't have any source code for that vb .exe file its a third party software.
Its an very urgent one....
please guide me how to do it with all steps.
Any material please pass to [email protected]
Thanks in advance.form grosswt .
refresh itab3.
clear itab3.
Executing VB EXE file to get the weight from weigh bridge
call function 'WS_EXECUTE'
exporting
DOCUMENT = ' '
CD = ' '
COMMANDLINE = ' '
inform = 'X'
cd = 'C:\SAPWEI'
program = 'C:\sapwei\MyVB.exe'
STAT = ' '
WINID = ' '
OSMAC_SCRIPT = ' '
OSMAC_CREATOR = ' '
WIN16_EXT = ' '
EXEC_RC = ' '
IMPORTING
RBUFF =
EXCEPTIONS
FRONTEND_ERROR = 1
NO_BATCH = 2
PROG_NOT_FOUND = 3
ILLEGAL_OPTION = 4
GUI_REFUSE_EXECUTE = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Fetching Value from VB text file
call function 'WS_UPLOAD'
exporting
CODEPAGE = ' '
filename = 'C:\sapwei\w1.txt'
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
tables
data_tab = itab3
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
loop at itab3.
v1 = itab3-num.
pgrwt = v1.
endloop.
message 'Save Gross Weight' type 'S'.
endform. " grosswt -
Running a batch file - VERY URGENT .. help
Hi people
I am attempting to run a batch file from with a JSP page.
the code i am using is:
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("cmd.exe /c d:\\uploadfiles.bat");
This jsp file is located on the c: of a webserver.
the uploadfiles.bat is located on the d: of the webserver and the code is:
copy d:\videos\008214?.rm d:\blah
copy d:\images\008214.* d:\blah
copy d:\xml\008214.* d:\blah
cd \blah
pkzip -es -m 008214.zip *.*
copy 008214.zip d:\upload\008214.zip
del 008214.zip
If I run this batch file from a command line, it works fine, though when I try and call it through my JSP page, it doesnt do anything .. a command window just pops up for a while, and then closes.
How can I fix this ... I need this quite quickly
Thanks people1) It is O.K. that you see nothing in that console. Its output is captured by Java and is not displayed on the screen.
In general, that console should not be visible, but actually it behaves differently according to JDK and OS versions (treat that as a feature).
2). Look at this article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
It it does not answer your problem, try to search the forums:
http://search.java.sun.com/search/java/index.jsp?qp=%2Bforum%3A31&nh=10&qt=%2B%22exec%22+-%22Replies%3A+0%22&col=javaforums
Questions about Runtime.exec() has been asked hundreds of times.
3) runtime.exec() can execute BAT files. It is not necessary to specify that "cmd /C". -
How to load a Properties file : Very URGENT
I have properties file ie., SQLProperties.properties
SQLProperties.properties
logdetails = SELECT USERNAME AND PASSWORD FROM USER_TBL
I want to load this file .
I used like this
public static Properties prop = null;
strKey ="logdetails";
FileInputStream fis = new FileInputStream("SQLProperties.properties");
prop.load(fis); // Since load parameter is file input stream
prop.getProperty(strKey);But it is coming error while loadingYou did not initialize prop.
//public static Properties prop = null;
public static Properties prop = new Properties ();
strKey ="logdetails";
FileInputStream fis = new FileInputStream("SQLProperties.properties");
prop.load(fis); // Since load parameter is file input stream
prop.getProperty(strKey);
[/prop] -
Create a batch file "very urgent"
i want to create a batch file that run every hour to update the user_status table fields according to the following formula
if login = 1 and login_time status = 0 then login =3Write this statement into a text file and name it as
say test.sql
UPDATE user_status
SET login = 3
WHERE login = 1
AND login_time = 0;Then write a script in UNIX as following
$vi test_script.ksh
!# /bin/ksh
sqlplus `@test.sql`save it
write a crom job for every hour.
Codes not tested...
Hope this helps
Ghulam -
About XLIFF translation File Very urgent
Dear all ,
I am trying to translate the error messages in the APEX using the file XLIFF
I did the following :
1-Map your primary language application to a translated application
2-Seed and export the translation text of your application into a translation file.
3-Translate text identified in translation file.
4-Apply your translation file and publish.
but it didnt display the translation for the messages,so I opened the XLIFF file and i saw all the messages in the application inside the file but it is not translated,
so i changed it manually from the file itself then i exported the translation file into the application and i publish it ..
but it didnt make any effect to the application i checked the file itself it is changed there but it doesnt make effect on the application ...
actually i need to change the file manually from the OS not from the application coz it will not show all the component of the file ..
Thanks in advance
Regards
Ahmed ......Hi,
SAP BC and SAP NetWeaver are based on different technologies: SAP BC is based
on webMethods proprietary Integration Server, whereas SAP NetWeaver is based
on open standards, such as BPEL4WS (business process execution language for
web services). Therefore, only parts of an SAP BC implementation, such as XSLT
mappings, can be migrated to a solution based on SAP NetWeaver. Any custom
programming based on SAP BC, such as SAP BC flow language, is unlikely to be
reusable in the SAP NetWeaver context.
The basic steps in the back-end systems are:
Defining the logical systems
Maintaining the ALE distribution model
Maintaining partner profiles and EDI ports
Maintaining RFC destinations
The basic steps in the SAP XI system are:
Maintaining the System Landscape Directory
Configuring the IDoc adapter
Maintaining the receiver determinations, interface determinations, and
interface agreements
Maintaining the communication channels
The type of scenario to migrate typically has an impact on the communication channels only.
>>>how to migrate from BC to XI in this kind of scenario. Will i use RFC and File adapters in my XI to configure the same?
Yes , for RFC communication you need to use the RFC adapter as you know in BC you need to create the connections and you can also test you RFC and BAPI and also you can check what XML string is coming in return. So i guess that XML you can use in XI also. Also you can use file adapter.
Hope this will help you.
Regards
Aashish Sinha
PS : reward points if helpful -
how can i create a text file using 'comma' as delimiter.moreover table is having
around million records,i want to create a sy for eg.about 10 thousansd.is it a
time consuming process.Pls help meUsing SQL*Plus to format the output is easiest way
set colsep ,
set lines 1000
set pages 1000 -- or you can use pages 0 to suppress the column headings
spool output.txt
select * from emp where rownum < 10
spool off
EMPNO,ENAME ,JOB , MGR,HIREDATE , SAL, COMM, DEPTNO
7369,SMITH ,CLERK , 7902,17-DEC-80, 800, , 20
7499,ALLEN ,SALESMAN , 7698,20-FEB-81, 1600, 300, 30
7521,WARD ,SALESMAN , 7698,22-FEB-81, 1250, 500, 30
7566,JONES ,MANAGER , 7839,02-APR-81, 2975, , 20
7654,MARTIN ,SALESMAN , 7698,28-SEP-81, 1250, 1400, 30
7698,BLAKE ,MANAGER , 7839,01-MAY-81, 2850, , 30
7782,CLARK ,MANAGER , 7839,09-JUN-81, 2450, , 10
7788,SCOTT ,ANALYST , 7566,19-APR-87, 3000, , 20
7839,KING ,PRESIDENT, ,17-NOV-81, 5000, , 10
You can play around with your SQL and column data format to how you want
Cheers
Dave -
Not able to download the field names in GUI_DOWNLOAD(very urgent)
Hi All,
I am downloading the file contents to the presentation server.i am able to get the file contents proeprly but not able to download the field names into text file.
Can anybody please help me in this issue..? its very urgent. Valuable answers will be rewarded.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = w_filename
filetype = 'DAT'
write_field_seperator = c_x
col_select = c_x
COL_SELECT_MASK = t_mask
TABLES
data_tab = t_tab
fieldnames = t_colnames
EXCEPTIONS
Thanks & Regards,
Satish.Hi,
I have tried in both ways its not working.
while a ran the program it is going to the dump.
I am working in mySAP ECC6.0
Can pl you suggest other way..
Thanks & Regards,
Satish. -
Upload file in clustered environment- Very Urgent
Hi,
My requirement is to upload a file onto the WebServer and also list out the file names on the front end and provide a funcionality to delete them from the server.
Environment Details:
-Product: WebSphere Portal
-Type - Clustered Enviroment with 2 nodes
-Framework: JSF
The problem I am facing here is:
1) I login to the application using a common URL: Say abc.com/wps/portal
2) I dont know which node I am logged into, it can be either Primary(X1) or Secondary(X2).
3) I click on the browse button and select a file and click on the Upload button. The file is uploaded successfully on say primary node X1.
4) I can at that time read the name of the file and display it on screen and also select and delete it. But if I log off and login again and say I am now redirected to secondary node, I am not able to read the name of the file I uploaded as it is stored on the primary node.
Can some body provide me a solutions to this.
What I can think of is , While uploading the file, I will check if I am on the primary node or secondary node and Upload the file only on one node rather than uploading them on both. Say uploading only on primary node X1, Now if I am logged into primary I can just mention the directory name and upload it.
But I f am on the secondary node I need to upload the file on the primary node using URL connection.
Can some body tell me the feasibility of this approach ?? Also how do I upload a file on a remote machine(Logged into the secondary but putting the file onto the primary node.) ???
Please help me this very very urgent.
Thanks.Hi!
I would simply use a network share which is accessible from both nodes as storage. This way you don't have to care to which server the file is uploaded too, because both share the same filesystem.
If you are on windows, simply share a folder and access it from both nodes. In Linux I'd suggest using samba & mount, on solaris use share & mount.
Another approach would be to use a database as storage.
hth Chris -
Very urgent..Can a batch file be executed from a button in application?
HI!
Please this is very urgent..
I want to know wheather it is possible to provide a button in an htmldb application,
that executes a batch(dos .bat file) file from a network location????
Thanks
Asit.
Message was edited by:
user459887It will be possible to do that but I suggest you search the HTML DB Forum first and place your question there rather than in this forum .
Greg -
Urgent!! downloading file in jsp
hi all
can anyone plz help me in downloading file from my disk
actual scenario is like this
i have uploaded file path in database, and whole file in to my disk....
i have given links to file name and when one clicks the link the file of that link should be downloaded / opened from the path specified in the database
its really too urgent
plz help me outThe replies on this post : http://forum.java.sun.com/thread.jspa?threadID=5170452&messageID=9655276 should give you some idea
-
Very Urgent, files, threads, and swing !!!!
Dear friends, i have a swing application, in that application i have a class that extends a thread, that thread will do nothing but read the contents of my data file and puts them in an array, but i am getting a NullpointerException in my thread, could any friend help me please, it is very urgent, i will post my code below.
import java.awt.*;
import java.awt.event.*;
import java.text.DateFormat;
import java.util.*;
import javax.swing.*;
import java.sql.*;
import java.net.URL;
import java.io.*;
public class FinalMachine extends JFrame
private JPanel MainPanel, ThicknessPanel, MainManager,fieldsPanel, sub_panel;
private Container c;
private CardLayout CardManager;
private String timezone;
private static final int ONE_SECOND = 1000;
private JLabel welcome_label, label1, label2, label3,field_label;
private JTextField data_entry;
private Connection connection;
public JPanel thick_figure;
public int num_of_hits, next_index, recCount;
public int dataBuffer[];
public FileReader data_file;
public BufferedReader b_data_file;
public File tem_file;
final int num_of_rec = 20;
public FinalMachine()
super("PHOENIX MACHINERY s.a.l");
/* Start all threads */
/* Start filling data file in global array */
loadData dataFile = new loadData();
dataFile.start();
/* Adding control to window application */
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowevent)
// setDefaultCloseOperation(0);
System.exit(0);
public void windowDeiconified(WindowEvent eve)
setState(0);
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent componentevent)
setSize(500, 500);
Dimension dimension1 = Toolkit.getDefaultToolkit().getScreenSize();
if(dimension1.width == 800 && dimension1.height == 600)
setLocation(150, 25);
else
if(dimension1.width == 1024 && dimension1.height == 768)
setLocation(200, 100);
/* Setting the location of the application on the screen */
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
if(dimension.width == 800 && dimension.height == 600)
setLocation(150, 25);
else
if(dimension.width == 1024 && dimension.height == 768)
setLocation(200, 100);
/* Constructing the main menu */
JMenuBar bar = new JMenuBar();
setJMenuBar( bar );
JMenu fileMenu = new JMenu( "File");
fileMenu.setMnemonic( 'F' );
JMenuItem mainItem = new JMenuItem( "Main page" );
mainItem.setMnemonic( 'M' );
mainItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
CardManager.show(MainManager, "main");
fileMenu.add( mainItem );
JMenuItem dataItem = new JMenuItem( "Database page" );
dataItem.setMnemonic( 'D' );
dataItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
CardManager.show(MainManager, "data_base");
fileMenu.add( dataItem );
JMenuItem printItem = new JMenuItem( "Print" );
printItem.setMnemonic( 'P' );
printItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
PrintUtilities.printComponent(MainManager);
fileMenu.add( printItem );
JMenuItem exitItem = new JMenuItem( "Exit" );
exitItem.setMnemonic( 'P' );
exitItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
System.exit(0);
fileMenu.add( exitItem );
bar.add( fileMenu );
JMenu figureMenu = new JMenu( "Figures");
figureMenu.setMnemonic( 'G' );
JMenuItem thicknessItem = new JMenuItem( "Thickness" );
thicknessItem.setMnemonic( 'T' );
thicknessItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
CardManager.show(MainManager, "thickness");
figureMenu.add( thicknessItem );
bar.add( figureMenu );
JMenu helpMenu = new JMenu( "Help");
helpMenu.setMnemonic( 'H' );
JMenuItem aboutItem = new JMenuItem( "About us" );
aboutItem.setMnemonic( 'A' );
aboutItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
JOptionPane.showMessageDialog(null, "Engineer Bilal Haidar (Computer & "+ "Communication Engineering)\n\n All Rights Reserevd. @ 2002",
"About me...", JOptionPane.PLAIN_MESSAGE);
helpMenu.add( aboutItem );
bar.add( helpMenu );
/* Intializing global values */
dataBuffer = new int[60];
/* Initializing the panels */
c = getContentPane();
c.setLayout(new FlowLayout());
CardManager = new CardLayout();
MainManager = new JPanel(false);
MainManager.setLayout(CardManager);
c.add(MainManager);
javax.swing.border.Border border = BorderFactory.createEmptyBorder(10, 10, 5, 10);
MainPanel = new JPanel(false);
MainPanel.setLayout(new BoxLayout(MainPanel, 1));
MainPanel.setBorder(border);
ThicknessPanel = new JPanel(false);
ThicknessPanel.setLayout(new BoxLayout(ThicknessPanel, 1));
ThicknessPanel.setBorder(border);
fieldsPanel = new JPanel(false);
fieldsPanel.setLayout( new BoxLayout( fieldsPanel,1));
fieldsPanel.setBorder(border);
sub_panel = new JPanel(false);
sub_panel.setLayout( new BoxLayout(sub_panel,0) );
sub_panel.setBorder(border);
thick_figure = new JPanel(false);
thick_figure.setBorder(border);
/* Filling the main panel */
JLabel jlmain = new JLabel("Main Page");
MainPanel.add(jlmain);
timezone = showTime(new Locale("en", "US"));
JLabel jltime = new JLabel(" " + timezone);
MainPanel.add(jltime);
MainManager.add(MainPanel, "main");
/* Filling the thickness panel */
num_of_hits = 0;
next_index = 0;
/* fill in with ero values for everything*/
/*display the figure*/
ThicknessPanel.add(thick_figure);
JLabel blanklabel = new JLabel(" ");
ThicknessPanel.add(blanklabel);
JButton build_fig = new JButton("Draw Figure");
build_fig.addActionListener(
new ActionListener() { // anonymous inner class
public void actionPerformed( ActionEvent e )
if ( num_of_hits == 0 )
/* draw figure based on first 20 points in the array */
next_index = num_of_rec;
else
if ( num_of_hits > 3 )
JOptionPane.showMessageDialog(null,"No more data to draw","Error Drawing",JOptionPane.ERROR_MESSAGE);
else
/* draw the figure starting the data from index 20*/
next_index = next_index + num_of_rec;
num_of_hits += 1;
ThicknessPanel.add(build_fig);
MainManager.add(ThicknessPanel, "thickness");
/* filling the database panel */
label1 = new JLabel(" ",SwingConstants.CENTER);
welcome_label = new JLabel(" Database Page ",SwingConstants.CENTER);
label2 = new JLabel(" ",SwingConstants.CENTER);
fieldsPanel.add( label1 );
fieldsPanel.add( welcome_label );
fieldsPanel.add( label2 );
field_label = new JLabel(" Enter your name: ");
data_entry = new JTextField( 10 );
sub_panel.add( field_label );
sub_panel.add( data_entry );
fieldsPanel.add( sub_panel );
JButton add_data = new JButton( "Add me" );
add_data.addActionListener(
new ActionListener() { // anonymous inner class
public void actionPerformed( ActionEvent e )
// try {
// url = "jdbc:odbc:DataEntry";
// Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
// connection = DriverManager.getConnection( url );
// System.out.println( "Connection Suucessfull");
// Statement statement = connection.createStatement();
// String get_field;
// get_field = data_entry.getText();
// String query = "INSERT INTO data (anyField) VALUES ('get_field')";
// int result1 = statement.executeUpdate( query );
// if ( result1 == 1 )
// JOptionPane.showMessageDialog(null, "Thanks for the info..."," Data Entry Success",JOptionPane.INFORMATION_MESSAGE);
// else
// JOptionPane.showMessageDialog(null, "Sorry, your name was not added...","Data entry error",JOptionPane.ERROR_MESSAGE);
// catch ( ClassNotFoundException cnfex ) {
// // process ClassNotFoundExceptions here
// cnfex.printStackTrace();
// System.out.println( "Connection UN Suucessfull");
// catch ( SQLException sqlex ) {
// // process SQLExceptions here
// sqlex.printStackTrace();
// System.out.println( "Connection UN Suucessfull");
// catch ( Exception ex ) {
// // process remaining Exceptions here
// ex.printStackTrace();
// System.out.println( "Connection UN Suucessfull");
fieldsPanel.add(add_data);
MainManager.add(fieldsPanel, "data_base");
/* display time */
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent actionevent)
timezone = showTime(new Locale("en", "US"));
setTitle("PHOENIX MACHINERY s.a.l " + timezone);
timer.start();
public static void main(String args[])
FinalMachine finalmachine = new FinalMachine();
finalmachine.setSize(500, 500);
ImageIcon imageicon = new ImageIcon("images/pc.gif");
finalmachine.setIconImage(imageicon.getImage());
finalmachine.show();
public static String showTime(Locale locale)
java.util.Date date = new java.util.Date();
byte byte0 = 2;
DateFormat dateformat = DateFormat.getTimeInstance(byte0, locale);
String s = dateformat.format(date);
return s;
/* Thread loadData starts here */
class loadData extends Thread
public void run()
try {
readMyFile();
catch( Exception x )
System.out.println("The following error occured in LoadData thread : "+x.toString() ); }
} // run() ends here
/* method read file inside thread loadData */
void readMyFile() {
String record = " ";
recCount = 0;
try {
tem_file = new File("mydata.dat");
data_file = new FileReader(tem_file);
b_data_file = new BufferedReader( data_file );
record = new String();
while ( (record = b_data_file.readLine()) != null ) {
dataBuffer[recCount] = Integer.parseInt(record);
recCount += 1; }
b_data_file.close();
catch (IOException e) {
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
} // end of readMyFile()
} // thread loadData ends
mydata.dat
2
4
3
1
2
3
5
2
4
1
6
3
2
5
4
1
2
5
8
2
6
9
7
4
2
1
0
2
5
4
8
7
5
6
3
2
1
4
3
0
2
3
6
5
2
1
4
5
6
9
8
5
2
1
6
8
3
1
7
5Thank you Mr. jobuck, you helped me a lot, i wonder if you can provide me with a tutorial on how threads work and how runnables work too. i fixed the error ut old me about but still when i try to add another thread to my program i got an error saying that, i must decalre the new thread in a seperate file please can u have a look on what i have:
import java.awt.*;
import java.awt.event.*;
import java.text.DateFormat;
import java.util.*;
import javax.swing.*;
import java.sql.*;
import java.net.URL;
import java.io.*;
public class FinalMachine extends JFrame
private JPanel MainPanel, ThicknessPanel, MainManager,fieldsPanel, sub_panel;
private Container c;
private CardLayout CardManager;
private String timezone;
private static final int ONE_SECOND = 1000;
private JLabel welcome_label, label1, label2, label3,field_label;
private JTextField data_entry;
private JPanel thick_figure;
private int num_of_hits, next_index, recCount, read_flag;
private int dataBuffer[];
private FileReader data_file;
private BufferedReader b_data_file;
private File tem_file;
private Connection connection;
final int num_of_rec = 20;
public FinalMachine()
super("PHOENIX MACHINERY s.a.l");
/* load JDBC drivers */
try {
String url = "jdbc:odbc:DataEntry";
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
connection = DriverManager.getConnection( url );
System.out.println( "Connection Suucessfull");
catch ( ClassNotFoundException cnfex ) {
// process ClassNotFoundExceptions here
cnfex.printStackTrace();
System.out.println( "Connection UN Suucessfull");
catch ( SQLException sqlex ) {
// process SQLExceptions here
sqlex.printStackTrace();
System.out.println( "Connection UN Suucessfull");
catch ( Exception ex ) {
// process remaining Exceptions here
ex.printStackTrace();
System.out.println( "Connection UN Suucessfull");
/* Intializing global values */
dataBuffer = new int[60];
/* Start all threads */
/* Start filling data file in global array */
loadData dataFile = new loadData();
dataFile.start();
setData setdata = new setData();
setdata.start();
/* Adding control to window application */
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowevent)
// setDefaultCloseOperation(0);
System.exit(0);
public void windowDeiconified(WindowEvent eve)
setState(0);
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent componentevent)
setSize(500, 500);
Dimension dimension1 = Toolkit.getDefaultToolkit().getScreenSize();
if(dimension1.width == 800 && dimension1.height == 600)
setLocation(150, 25);
else
if(dimension1.width == 1024 && dimension1.height == 768)
setLocation(200, 100);
/* Setting the location of the application on the screen */
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
if(dimension.width == 800 && dimension.height == 600)
setLocation(150, 25);
else
if(dimension.width == 1024 && dimension.height == 768)
setLocation(200, 100);
/* Constructing the main menu */
JMenuBar bar = new JMenuBar();
setJMenuBar( bar );
JMenu fileMenu = new JMenu( "File");
fileMenu.setMnemonic( 'F' );
JMenuItem mainItem = new JMenuItem( "Main page" );
mainItem.setMnemonic( 'M' );
mainItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
CardManager.show(MainManager, "main");
fileMenu.add( mainItem );
JMenuItem dataItem = new JMenuItem( "Database page" );
dataItem.setMnemonic( 'D' );
dataItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
CardManager.show(MainManager, "data_base");
fileMenu.add( dataItem );
JMenuItem printItem = new JMenuItem( "Print" );
printItem.setMnemonic( 'P' );
printItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
PrintUtilities.printComponent(MainManager);
fileMenu.add( printItem );
JMenuItem exitItem = new JMenuItem( "Exit" );
exitItem.setMnemonic( 'P' );
exitItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
System.exit(0);
fileMenu.add( exitItem );
bar.add( fileMenu );
JMenu figureMenu = new JMenu( "Figures");
figureMenu.setMnemonic( 'G' );
JMenuItem thicknessItem = new JMenuItem( "Thickness" );
thicknessItem.setMnemonic( 'T' );
thicknessItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
CardManager.show(MainManager, "thickness");
figureMenu.add( thicknessItem );
bar.add( figureMenu );
JMenu helpMenu = new JMenu( "Help");
helpMenu.setMnemonic( 'H' );
JMenuItem aboutItem = new JMenuItem( "About us" );
aboutItem.setMnemonic( 'A' );
aboutItem.addActionListener (
new ActionListener() {
public void actionPerformed( ActionEvent e )
JOptionPane.showMessageDialog(null, "Engineer Bilal Haidar (Computer & "+ "Communication Engineering)\n\n All Rights Reserevd. @ 2002",
"About me...", JOptionPane.PLAIN_MESSAGE);
helpMenu.add( aboutItem );
bar.add( helpMenu );
/* Initializing the panels */
c = getContentPane();
c.setLayout(new FlowLayout());
CardManager = new CardLayout();
MainManager = new JPanel(false);
MainManager.setLayout(CardManager);
c.add(MainManager);
javax.swing.border.Border border = BorderFactory.createEmptyBorder(10, 10, 5, 10);
MainPanel = new JPanel(false);
MainPanel.setLayout(new BoxLayout(MainPanel, 1));
MainPanel.setBorder(border);
ThicknessPanel = new JPanel(false);
ThicknessPanel.setLayout(new BoxLayout(ThicknessPanel, 1));
ThicknessPanel.setBorder(border);
fieldsPanel = new JPanel(false);
fieldsPanel.setLayout( new BoxLayout( fieldsPanel,1));
fieldsPanel.setBorder(border);
sub_panel = new JPanel(false);
sub_panel.setLayout( new BoxLayout(sub_panel,0) );
sub_panel.setBorder(border);
thick_figure = new JPanel(false);
thick_figure.setBorder(border);
/* Filling the main panel */
JLabel jlmain = new JLabel("Main Page");
MainPanel.add(jlmain);
timezone = showTime(new Locale("en", "US"));
JLabel jltime = new JLabel(" " + timezone);
MainPanel.add(jltime);
MainManager.add(MainPanel, "main");
/* Filling the thickness panel */
num_of_hits = 0;
next_index = 0;
/* fill in with ero values for everything*/
/*display the figure*/
ThicknessPanel.add(thick_figure);
JLabel blanklabel = new JLabel(" ");
ThicknessPanel.add(blanklabel);
JButton build_fig = new JButton("Draw Figure");
build_fig.addActionListener(
new ActionListener() { // anonymous inner class
public void actionPerformed( ActionEvent e )
if ( num_of_hits == 0 )
/* draw figure based on first 20 points in the array */
next_index = num_of_rec;
else
if ( num_of_hits > 3 )
JOptionPane.showMessageDialog(null,"No more data to draw","Error Drawing",JOptionPane.ERROR_MESSAGE);
else
/* draw the figure starting the data from index 20*/
next_index = next_index + num_of_rec;
num_of_hits += 1;
ThicknessPanel.add(build_fig);
MainManager.add(ThicknessPanel, "thickness");
/* filling the database panel */
label1 = new JLabel(" ",SwingConstants.CENTER);
welcome_label = new JLabel(" Database Page ",SwingConstants.CENTER);
label2 = new JLabel(" ",SwingConstants.CENTER);
fieldsPanel.add( label1 );
fieldsPanel.add( welcome_label );
fieldsPanel.add( label2 );
field_label = new JLabel(" Enter your name: ");
data_entry = new JTextField( 10 );
sub_panel.add( field_label );
sub_panel.add( data_entry );
fieldsPanel.add( sub_panel );
JButton add_data = new JButton( "Add me" );
add_data.addActionListener(
new ActionListener() { // anonymous inner class
public void actionPerformed( ActionEvent e )
try {
Statement statement = connection.createStatement();
String get_field;
get_field = data_entry.getText();
String query = "INSERT INTO data (anyField) VALUES ('"+get_field+"')";
int result1 = statement.executeUpdate( query );
if ( result1 == 1 )
JOptionPane.showMessageDialog(null, "Thanks for the info..."," Data Entry Success",JOptionPane.INFORMATION_MESSAGE);
data_entry.setText(" ");
else
JOptionPane.showMessageDialog(null, "Sorry, your name was not added...","Data entry error",JOptionPane.ERROR_MESSAGE);
catch ( SQLException sqlex ) {
// process SQLExceptions here
sqlex.printStackTrace();
System.out.println( "Connection UN Suucessfull");
catch ( Exception ex ) {
// process remaining Exceptions here
ex.printStackTrace();
System.out.println( "Connection UN Suucessfull");
fieldsPanel.add(add_data);
MainManager.add(fieldsPanel, "data_base");
/* display time */
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent actionevent)
timezone = showTime(new Locale("en", "US"));
setTitle("PHOENIX MACHINERY s.a.l " + timezone);
timer.start();
public static void main(String args[])
FinalMachine finalmachine = new FinalMachine();
finalmachine.setSize(500, 500);
ImageIcon imageicon = new ImageIcon("images/pc.gif");
finalmachine.setIconImage(imageicon.getImage());
finalmachine.show();
public static String showTime(Locale locale)
java.util.Date date = new java.util.Date();
byte byte0 = 2;
DateFormat dateformat = DateFormat.getTimeInstance(byte0, locale);
String s = dateformat.format(date);
return s;
/* Thread loadData starts here */
public class loadData extends Thread
public void run()
try {
readMyFile();
read_flag = 1;
notify();
catch( Exception x )
System.out.println("The following error occured in LoadData thread : "+x.toString() );
} // run() ends here
/* method read file inside thread loadData */
void readMyFile() {
String record = " ";
recCount = 0;
try {
tem_file = new File("mydata.dat");
data_file = new FileReader(tem_file);
b_data_file = new BufferedReader( data_file );
record = new String();
while ( (record = b_data_file.readLine()) != null ) {
dataBuffer[recCount] = Integer.parseInt(record);
recCount += 1; }
b_data_file.close();
catch (IOException e) {
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
} // end of readMyFile()
} // thread loadData ends
public class setData extends Thread {
public void run()
try {
while ( !read_flag ) {
try { wait(); }
catch( InterruptedException e ) {
e.printStackTrace();
} // end while
for(int index = 0; index < 60; index++)
System.out.println("Array["+index+"] = "+dataBuffer[index]);
catch( Exception x )
System.out.println("The following error occured in LoadData thread : "+x.toString() );
} // run() ends here
the only added thing is the setData thread, i want this thread to start printing out the array whenever, loadData thread has finished filling the data inside the array please i need ur help. -
How use class file in jsp(very urgent)
i have class file called birds (birds is actually a xslt file transformed to java class file) now this class file i have to use in my jsp file. how can i use them. if possible can any one give me sample code please very urgent
can any one help mejava files
import org.w3c.dom.*;
import javax.servlet.http.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import java.io.*;
public class XmlParser
public String XmlParser()
try
String strXML= "employee.xml";
String xslFile = "employeeId.xsl";
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamResult theTransformationResult = new StreamResult( new ByteArrayOutputStream() );
Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
transformer.transform(new StreamSource(new StringReader(strXML)), theTransformationResult);
String output = theTransformationResult.getOutputStream().toString()
catch(Exception e)
System.out.println(" ***** XmlParser.XmlParser ERROR ***** " + e);
return output;
using class files in jsp
<%@ page import="com.qqqq.aaaa.XmlParser"%>
<%
XmlParser xmlParser = new XmlParser();
out.println(xmlParser.XmlParser());
%>
i think it will help you. -
How to send Zip files as attachments !! Very urgent, Please help!
I am sending PDF files as attachments using java mail (it works fine). But now my requirement is to zip the PDFs and send them as attachments instead of actual PDF's. But i don't know how to achieve that. does java mail API support zip attachment facilities? I have looked in activation API also, but i couldn't find anything helpful. even i searched the forums, but no clue. Please, anybody help me about this, it's very urgent.
thanks
sriCheck the first "if". If I specify an attachment, then a myme multipart doby is created: one for text and the other for the attachemnt I use this myme ovbject only for attachemnts, because some ISPs have problems and report error in email format if the attachemnet is missing and it contains only text and no attachment.
static public void send(String to,
String from,
String host,
String smtpPort,
String subject,
String body,
String fileAttachment,
String attachmentMimeType,
String username,
String password,
String debug)
throws Exception
// create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", smtpPort);
props.put("mail.smtp.timeout","5000");
props.put("mail.debug", debug);
Session session = null;
if (username != null && password != null)
props.put("mail.smtp.auth", "true");
MyPasswordAuthenticator auth = new MyPasswordAuthenticator(username, password);
session = Session.getDefaultInstance(props,auth);
else
session = Session.getDefaultInstance(props, null);
//session.setDebug(true);
// create a message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
InternetAddress[] address = InternetAddress.parse(to, false);
message.setRecipients(Message.RecipientType.TO, address);
message.setSubject(subject);
message.setSentDate(new Date());
// create the message part
if ( fileAttachment != null && fileAttachment != "NO" )
MimeBodyPart messageBodyPart = new MimeBodyPart();
//fill message
messageBodyPart.setText(body);
//Multipart multipart = new MimeMultipart();
Multipart multipart = new MimeMultipart("alternative");
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
System.out.println("----->fileAttachment DISTINTO de NULL");
messageBodyPart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler( new DataHandler(fds));
messageBodyPart.setFileName(fileAttachment); //<-- El archivo atachado.
multipart.addBodyPart(messageBodyPart);
//EN DESARROLLO el envio de attachment!!
// Put parts in message
message.setContent(multipart);
} else { //Envio es solamente TEXTO
message.setText(body);
// send the message
Transport.send(message);
Regards,
Vladimir -
Downloading files using HttpConnection is very slow
Hi
I've written a program which will download files over HTTP protocol using the class HttpConnection. I am connecting to the net using Proxy with authorization. At times it takes long time to download even a 2 MB file, but it works very fast on fewer occasions. The same file If I try to download using browser such as IE or FireFox, download happens in few seconds.
I am not sure where the problem is. Can anyone guide me on this issue?
Regards,
FaisalThe HTTPUrlConnection do not seem to utilize the
Connection Keep Alive feature of HTTP so it createa
seperate connection for each request.Eh? The Sun implementation can utilize HTTP
Connection Keep Alive if you tell it to, and it also
runs a connection pool.Great! can you explain a bit how you enable it?
Can I just do it by setting the Connection: Keep-Alive header
Maybe you are looking for
-
Tried to update my ipad mini and it is now stuck in recovery mode
Do i lose all of the data on that ipad now?
-
How to delete cookies in Windows 7 - info on website is only for xp.
there is no info on how to delete cookies on windows 7. Please provide method.
-
External Btach Number for Finished Goods
Hi All.... We have a repetitive mfg scenario, where finished goods are managed with external batch numnber. Client has 20+ plants and each plant follows its own number ranges... In each plant,each product shud have continuous batch numbers, eg., Pro
-
Can I refresh photo stream to backup old photos to icloud?
There must be an easier way to transfer keepsakes from an old phone to new. I've had a 4s for nearly 2 years and upgraded to the 5. I understand photo stream only backs up photos that are 30 days old, so what can be done to keep all of them? It doesn
-
Hi, Is there any SAP quicksizer that can be used to give us an estimate of AUTO-ID TOOL based on these metrics? - 300 transactions per day - Each interfaced data packet ~1270 bytes - 10 simultaneous users How do I search fo