Re: Servlet and Random Access File

2007-05-30 Thread Teh Noranis Mohd Aris
I would like to refer to an example servlet where I can add fields (such as 
name, staff number, etc...) to a random access file and view the file 
information by accessing the field (eg. staff number). Please help. Thank you.
   
  Yours Sincerely,
  TEH  

David Smith [EMAIL PROTECTED] wrote:
  The key phrase here is ...that really suits my needs. Could you 
provide more information? Your question is a rather generic one not all 
that specific to java servlets.

--David


Teh Noranis Mohd Aris wrote:

Hello All,
 
 Does anyone have an example of a servlet program that uses random access file 
 or any useful links? I tried searching yahoo and google but could not find 
 one that really suits my needs. Thank you.
 
 Yours Sincerely,
 TEH 

 
-
 Get your own web address.
 Have a HUGE year through Yahoo! Small Business.
 



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



   
-
Get the free Yahoo! toolbar and rest assured with the added security of spyware 
protection. 

Re: Using servlet and mysql

2007-05-29 Thread Teh Noranis Mohd Aris
Dear All,
   
  I already put mysql database driver (jar file) in directory 
catalina_home\common\lib and changed 8080 to 3306 but I got the error 
java.sql.SQLException: Unable to connect to any hosts due to exception: 
java.net.ConnectException: Connection refused: connect. What should be the 
matter? I put the database name, teh in directory catalina_home\webapps\ROOT\. 
Is this correct? In which directory should I actually put the database name? 
Please help. I'm running out of time! Thank you so much.
   
  Yours Sincerely,
  TEH

Foo Shyn [EMAIL PROTECTED] wrote:
  Hi,

You'll need to get the MySQL database driver and put them in the 
{catalina_home}\common\lib folder. The driver can be easily obtained 
through MySQL site.
BTW, as far as i know, the default port for MySQL database is 3306, so 
you might wanna change that. 8080 is for Tomcat, not the database.

Seems like not many new users of connection pooling went through 
Apache's documents. Please don't waste their effort, take a look at it 
before you start to attempt anything.

HTH,
FooShyn

Teh Noranis Mohd Aris wrote:
 Thank you so much for the reply. I've put jdbc:mysql://localhost:8080/teh 
 but I got the error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. 
 I'm very new to using mysql database and servlet. Can you please explain to 
 me how to create the database name and its fields? Should I install any 
 driver? How can it be done? Please help. Thank you.
 
 Yours Sincerely,
 TEH 

 Foo Shyn wrote:
 Hi,

  would be ur database port, xxx will be ur database name

 HTH
 FooShyn

 Teh Noranis Mohd Aris wrote:
 
 Hi,

 I would like to access mysql database from a servlet but I'm not sure what 
 to initialize for the String connectionURL marked as 
 jdbc:mysql://localhost:/xxx in the program below. I got this program 
 from the internet which I would like to run in my computer. Can anyone 
 please explain to me what the parameters  and xxx should be?

 Yours Sincerely,
 TEH

 Following is part of the program:
 ...
 public void doPost(HttpServletRequest request, HttpServletResponse 
 response) throws ServletException, IOException{
 response.setContentType(text/html);
 PrintWriter pw = response.getWriter();
 String connectionURL = jdbc:mysql://localhost:/xxx;
 Connection connection=null;
 try{
 String username = request.getParameter(username);
 String password = request.getParameter(password);
 pw.println(username);
 pw.println(password);
 Class.forName(com.mysql.jdbc.Driver).newInstance();
 connection = DriverManager.getConnection(connectionURL, root, root);
 PreparedStatement pst = connection.prepareStatement
 (insert into login_table values(?,?));
 ...


 -
 Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, 
 when. 

 

 No virus found in this incoming message.
 Checked by AVG Free Edition. 
 Version: 7.5.472 / Virus Database: 269.8.0/821 - Release Date: 5/27/2007 
 3:05 PM

 


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 
 -
 Shape Yahoo! in your own image. Join our Network Research Panel today!
 
 

 No virus found in this incoming message.
 Checked by AVG Free Edition. 
 Version: 7.5.472 / Virus Database: 269.8.0/821 - Release Date: 5/27/2007 3:05 
 PM
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



   
-
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos  more. 

Re: Using servlet and mysql

2007-05-29 Thread Teh Noranis Mohd Aris
Yes, the login name and password are correct. I created the database name, teh, 
with field username and password, using Microsoft Works Database and saved it 
in directory catalina_home\webapps\ROOT\. I'm not sure whether it is the 
correct directory to put the database. However, in the program there was a 
statement .(insert into login_table values(?,?)); I do not understand the 
usage of login_table. Does it mean that I should create login_table in database 
teh? Really need to get this working today. Please help. Thank you.
   
  TEH
 

Foo Shyn [EMAIL PROTECTED] wrote:
  Hi,

Is your login name and password correct? It shows 'root' and the 
password is 'root' in the code you posted there.

- I put the database name, teh in directory catalina_home\webapps\ROOT\
hmm i can't really get what you meant here.

Thanx.
FooShyn

Teh Noranis Mohd Aris wrote:
 Dear All,
 
 I already put mysql database driver (jar file) in directory 
 catalina_home\common\lib and changed 8080 to 3306 but I got the error 
 java.sql.SQLException: Unable to connect to any hosts due to exception: 
 java.net.ConnectException: Connection refused: connect. What should be the 
 matter? I put the database name, teh in directory 
 catalina_home\webapps\ROOT\. Is this correct? In which directory should I 
 actually put the database name? Please help. I'm running out of time! Thank 
 you so much.
 
 Yours Sincerely,
 TEH

 Foo Shyn wrote:
 Hi,

 You'll need to get the MySQL database driver and put them in the 
 {catalina_home}\common\lib folder. The driver can be easily obtained 
 through MySQL site.
 BTW, as far as i know, the default port for MySQL database is 3306, so 
 you might wanna change that. 8080 is for Tomcat, not the database.

 Seems like not many new users of connection pooling went through 
 Apache's documents. Please don't waste their effort, take a look at it 
 before you start to attempt anything.

 HTH,
 FooShyn

 Teh Noranis Mohd Aris wrote:
 
 Thank you so much for the reply. I've put jdbc:mysql://localhost:8080/teh 
 but I got the error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. 
 I'm very new to using mysql database and servlet. Can you please explain to 
 me how to create the database name and its fields? Should I install any 
 driver? How can it be done? Please help. Thank you.

 Yours Sincerely,
 TEH 

 Foo Shyn wrote:
 Hi,

  would be ur database port, xxx will be ur database name

 HTH
 FooShyn

 Teh Noranis Mohd Aris wrote:

 
 Hi,

 I would like to access mysql database from a servlet but I'm not sure what 
 to initialize for the String connectionURL marked as 
 jdbc:mysql://localhost:/xxx in the program below. I got this program 
 from the internet which I would like to run in my computer. Can anyone 
 please explain to me what the parameters  and xxx should be?

 Yours Sincerely,
 TEH

 Following is part of the program:
 ...
 public void doPost(HttpServletRequest request, HttpServletResponse 
 response) throws ServletException, IOException{
 response.setContentType(text/html);
 PrintWriter pw = response.getWriter();
 String connectionURL = jdbc:mysql://localhost:/xxx;
 Connection connection=null;
 try{
 String username = request.getParameter(username);
 String password = request.getParameter(password);
 pw.println(username);
 pw.println(password);
 Class.forName(com.mysql.jdbc.Driver).newInstance();
 connection = DriverManager.getConnection(connectionURL, root, root);
 PreparedStatement pst = connection.prepareStatement
 (insert into login_table values(?,?));
 ...


 -
 Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's 
 on, when. 

 

 No virus found in this incoming message.
 Checked by AVG Free Edition. 
 Version: 7.5.472 / Virus Database: 269.8.0/821 - Release Date: 5/27/2007 
 3:05 PM


 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




 -
 Shape Yahoo! in your own image. Join our Network Research Panel today!

 

 No virus found in this incoming message.
 Checked by AVG Free Edition. 
 Version: 7.5.472 / Virus Database: 269.8.0/821 - Release Date: 5/27/2007 
 3:05 PM

 


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 
 -
 Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, 
 news, photos  more. 
 
 

 No virus found in this incoming message.
 Checked by AVG Free

Re: Using servlet and mysql

2007-05-29 Thread Teh Noranis Mohd Aris
I'm very new to this. This is the first time I'm using mysql and servlet. I 
might be doing a lot of mistakes. I realized that I should not use Microsoft 
Works Database. How can I actually create the database name, table and its 
field using mysql? In which directory should I put the database? Please 
explain. Hoping for a reply. I really hope this simple program can run today. 
Thank you.
   
  TEH

Foo Shyn [EMAIL PROTECTED] wrote:
  Hi,

This is getting more confusing, you mentioned earlier that you're using 
MySQL but now it is a Microsoft Works Database. Hmmm perhaps i'm missing 
something?

Anyway, if the database you're using is something like an Access 
database, you'll just need to use the correct driver and point the URL 
to your database file. Can't help you here coz i never tried that before 
(Access is like from another world to me). Perhaps you should try other 
mailing list, and not Tomcat's.

HTH
FooShyn

Teh Noranis Mohd Aris wrote:
 Yes, the login name and password are correct. I created the database name, 
 teh, with field username and password, using Microsoft Works Database and 
 saved it in directory catalina_home\webapps\ROOT\. I'm not sure whether it is 
 the correct directory to put the database. However, in the program there was 
 a statement .(insert into login_table values(?,?)); I do not understand 
 the usage of login_table. Does it mean that I should create login_table in 
 database teh? Really need to get this working today. Please help. Thank you.
 
 TEH
 

 Foo Shyn wrote:
 Hi,

 Is your login name and password correct? It shows 'root' and the 
 password is 'root' in the code you posted there.

 - I put the database name, teh in directory catalina_home\webapps\ROOT\
 hmm i can't really get what you meant here.

 Thanx.
 FooShyn

 Teh Noranis Mohd Aris wrote:
 
 Dear All,

 I already put mysql database driver (jar file) in directory 
 catalina_home\common\lib and changed 8080 to 3306 but I got the error 
 java.sql.SQLException: Unable to connect to any hosts due to exception: 
 java.net.ConnectException: Connection refused: connect. What should be the 
 matter? I put the database name, teh in directory 
 catalina_home\webapps\ROOT\. Is this correct? In which directory should I 
 actually put the database name? Please help. I'm running out of time! Thank 
 you so much.

 Yours Sincerely,
 TEH

 Foo Shyn wrote:
 Hi,

 You'll need to get the MySQL database driver and put them in the 
 {catalina_home}\common\lib folder. The driver can be easily obtained 
 through MySQL site.
 BTW, as far as i know, the default port for MySQL database is 3306, so 
 you might wanna change that. 8080 is for Tomcat, not the database.

 Seems like not many new users of connection pooling went through 
 Apache's documents. Please don't waste their effort, take a look at it 
 before you start to attempt anything.

 HTH,
 FooShyn

 Teh Noranis Mohd Aris wrote:

 
 Thank you so much for the reply. I've put jdbc:mysql://localhost:8080/teh 
 but I got the error java.lang.ClassNotFoundException: 
 com.mysql.jdbc.Driver. I'm very new to using mysql database and servlet. 
 Can you please explain to me how to create the database name and its 
 fields? Should I install any driver? How can it be done? Please help. Thank 
 you.

 Yours Sincerely,
 TEH 

 Foo Shyn wrote:
 Hi,

  would be ur database port, xxx will be ur database name

 HTH
 FooShyn

 Teh Noranis Mohd Aris wrote:


 
 Hi,

 I would like to access mysql database from a servlet but I'm not sure what 
 to initialize for the String connectionURL marked as 
 jdbc:mysql://localhost:/xxx in the program below. I got this program 
 from the internet which I would like to run in my computer. Can anyone 
 please explain to me what the parameters  and xxx should be?

 Yours Sincerely,
 TEH

 Following is part of the program:
 ...
 public void doPost(HttpServletRequest request, HttpServletResponse 
 response) throws ServletException, IOException{
 response.setContentType(text/html);
 PrintWriter pw = response.getWriter();
 String connectionURL = jdbc:mysql://localhost:/xxx;
 Connection connection=null;
 try{
 String username = request.getParameter(username);
 String password = request.getParameter(password);
 pw.println(username);
 pw.println(password);
 Class.forName(com.mysql.jdbc.Driver).newInstance();
 connection = DriverManager.getConnection(connectionURL, root, root);
 PreparedStatement pst = connection.prepareStatement
 (insert into login_table values(?,?));
 ...


 -
 Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's 
 on, when. 

 

 No virus found in this incoming message.
 Checked by AVG Free Edition. 
 Version: 7.5.472 / Virus Database: 269.8.0/821 - Release Date: 5/27/2007 
 3:05 PM



 
 -
 To start a new topic, e-mail: users

Servlet and Random Access File

2007-05-29 Thread Teh Noranis Mohd Aris
Hello All,
   
  Does anyone have an example of a servlet program that uses random access file 
or any useful links? I tried searching yahoo and google but could not find one 
that really suits my needs. Thank you.
   
  Yours Sincerely,
  TEH 

 
-
 Get your own web address.
 Have a HUGE year through Yahoo! Small Business.

Using servlet and mysql

2007-05-28 Thread Teh Noranis Mohd Aris
Hi,
   
  I would like to access mysql database from a servlet but I'm not sure what to 
initialize for the String connectionURL marked as 
jdbc:mysql://localhost:/xxx in the program below. I got this program from 
the internet which I would like to run in my computer. Can anyone please 
explain to me what the parameters  and xxx should be?
   
  Yours Sincerely,
  TEH
   
  Following is part of the program:
  ...
  public void doPost(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException{
response.setContentType(text/html);
PrintWriter pw = response.getWriter();
String connectionURL = jdbc:mysql://localhost:/xxx;
Connection connection=null;
try{
String username = request.getParameter(username);
String password = request.getParameter(password);
pw.println(username);
pw.println(password);
Class.forName(com.mysql.jdbc.Driver).newInstance();
connection = DriverManager.getConnection(connectionURL, root, root);
PreparedStatement pst = connection.prepareStatement
(insert into login_table values(?,?));
  ...

   
-
Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, 
when. 

Re: Using servlet and mysql

2007-05-28 Thread Teh Noranis Mohd Aris
Thank you so much for the reply. I've put jdbc:mysql://localhost:8080/teh but 
I got the error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. I'm 
very new to using mysql database and servlet. Can you please explain to me how 
to create the database name and its fields? Should I install any driver? How 
can it be done? Please help. Thank you.
   
  Yours Sincerely,
  TEH 

Foo Shyn [EMAIL PROTECTED] wrote:
  Hi,

 would be ur database port, xxx will be ur database name

HTH
FooShyn

Teh Noranis Mohd Aris wrote:
 Hi,
 
 I would like to access mysql database from a servlet but I'm not sure what to 
 initialize for the String connectionURL marked as 
 jdbc:mysql://localhost:/xxx in the program below. I got this program 
 from the internet which I would like to run in my computer. Can anyone please 
 explain to me what the parameters  and xxx should be?
 
 Yours Sincerely,
 TEH
 
 Following is part of the program:
 ...
 public void doPost(HttpServletRequest request, HttpServletResponse 
 response) throws ServletException, IOException{
 response.setContentType(text/html);
 PrintWriter pw = response.getWriter();
 String connectionURL = jdbc:mysql://localhost:/xxx;
 Connection connection=null;
 try{
 String username = request.getParameter(username);
 String password = request.getParameter(password);
 pw.println(username);
 pw.println(password);
 Class.forName(com.mysql.jdbc.Driver).newInstance();
 connection = DriverManager.getConnection(connectionURL, root, root);
 PreparedStatement pst = connection.prepareStatement
 (insert into login_table values(?,?));
 ...

 
 -
 Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, 
 when. 
 
 

 No virus found in this incoming message.
 Checked by AVG Free Edition. 
 Version: 7.5.472 / Virus Database: 269.8.0/821 - Release Date: 5/27/2007 3:05 
 PM
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



   
-
Shape Yahoo! in your own image.  Join our Network Research Panel today!

Coverting Program to Servlet

2007-05-23 Thread Teh Noranis Mohd Aris
Dear All,
  The following program uses socket. How can I convert it to servlet? Please 
help. Thank you.
   
  Yours Sincerely,
  TEH
   
  import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
   
  public class Exercise18_3Server {
  // Declare a random access file
  RandomAccessFile raf = null;
public static void main(String args[]) {
new Exercise18_3Server();
  }
public Exercise18_3Server() {
// Open the local file on the server side
try {
  // Open the file if the file exists, create a new file if the file does 
not exist
  raf = new RandomAccessFile(student.dat, rw);
}
catch(IOException e) {
  System.out.print(Error:  + e);
  System.exit(0);
}
  // Establish server socket
try {
  // Create a server socket
  ServerSocket ss = new ServerSocket(8000);
  int count = 1;
ThreadGroup tg = new ThreadGroup(serving clients);
while (true) {
if (tg.activeCount()  2) {
  // Connect to a client
  Socket s = ss.accept();
// Start a new thread to register a client
  Thread t = new Thread(tg, new RegistrationThread(s, count++));
  t.start();
System.out.println(tg.activeCount() +  active threads);
}
else {
  try {Thread.sleep(200); }
  catch (InterruptedException ex) { }
}
  }
}
catch (IOException e) {
  System.err.println(e);
}
  }
  // Define a thread to process the client registration
class RegistrationThread extends Thread {
  private Socket sock;  // The socket to serve a client
private int num; //the socket label
// The file to store the records
  // Buffer reader to get input from the client
  private BufferedReader in;
  private PrintWriter out;
public RegistrationThread(Socket sock, int num) {
this.sock = sock;
this.num = num;
  System.out.println(Thread  + num +  running);
  // Create an input stream to receive data from a client
try {
  in = new BufferedReader
(new InputStreamReader(sock.getInputStream()));
  out = new PrintWriter(sock.getOutputStream(), true);
}
catch(IOException ex) {
  System.out.println(Error  + ex);
}
  }
public void run() {
String name;
String street;
String city;
String state;
String zip;
  try {
  // Get command
  String command = in.readLine();
if (command.equals(Register)) {
// Receive data from the client
name = new String(in.readLine());
street = new String(in.readLine());
city = new String(in.readLine());
state = new String(in.readLine());
zip = new String(in.readLine());
   // Display data received
 System.out.println(The following data received from the client);
System.out.println(name:  + name);
 System.out.println(street:  + street);
 System.out.println(city:  + city);
 System.out.println(state:  + state);
 System.out.println(zip:  + zip);
  // Create a student instance
Student s = new Student(name, street, city, state, zip);
  // Append it to student.dat
raf.seek(raf.length());
s.writeStudent(raf);
  }
  else if (command.equals(View)) {
name = new String(in.readLine());
Student s = search(name);
  if (s == null) {
  out.println(not found);
}
else {
  out.println(found);
  out.println(s.getStreet());
  out.println(s.getCity());
  out.println(s.getState());
  out.println(s.getZip());
}
  }
}
catch (IOException e) {
  System.err.println(e);}
}
  public Student search(String name) {
  Student s = new Student();
  try {
raf.seek(0);
long length = raf.length();
while (raf.getFilePointer()  length) {
  s.readStudent(raf);
  if (name.trim().equals(s.getName().trim())) return s;
  System.out.println(Find anything? + name ++ s.getName());
}
  }
  catch(IOException ex) {
System.out.print(Error:  + ex);
  }
return null;
  }
}
  class Student {
  private String name;
  private String street;
  private String city;
  private String state;
  private String zip;
// The size of five string fields in the record
  final int NAME_SIZE = 32;
final int STREET_SIZE = 32;
  final int CITY_SIZE = 20;
  final int STATE_SIZE = 2;
  final int ZIP_SIZE = 5;
// The total size of the record in bytes, a Unicode
  // character is 2 bytes size.*/
  final int RECORD_SIZE =
(NAME_SIZE + STREET_SIZE + CITY_SIZE + STATE_SIZE + ZIP_SIZE);
Student() {
  }
Student(String name, String street, String city,
  String state, String zip  ) {
this.name = name;
this.street = street;
this.city = city;
this.state = state;
this.zip = zip;
  }
public String getName() {
return name;
  }
public String getStreet() 

Re: Cannot Access Tomcat Server Using IP Address

2007-05-21 Thread Teh Noranis Mohd Aris
I already solve the problem. I fixed the program and it works! Thank you so 
much for the replies. 
   
  Yours Sincerely,
  TEH

Teh Noranis Mohd Aris [EMAIL PROTECTED] wrote:
  Yes, I can access the login.html interface from a different computer using 
http://IPaddress:8080/login.html but when I tried to access a file, I got the 
mentioned problem displayed in the text area. However, I can access a file if 
I'm using http://localhost:8080/login.html. I'm testing using Windows XP. What 
should I do? Thank you.

TEH 

Omar Eljumaily wrote:
I don't understand. Are you able to access login.html from outside your 
server machine? 

The socketpermerission problem you have sounds like a firewall issue or 
a administrator privileges problem not allowing you to accept incoming 
sockets. Are you running with administrator privs on XP?

XP and Linux deal with firewalls and permissions differently. Linux is 
a bit more straight forward in my opinion. You just accept queries on 
8080 and then redirect port 80 if you want to resolve static pages. 
SELinux can be an issue, but is usually simple to solve by tweaking a 
setting.

Teh Noranis Mohd Aris wrote:
 Thank you. It's working now, the application can be accessed but when I type 
 a file name to access a file in the server, I got an error 
 java.security.AccessControlException:access denied 
 (java.net.SocketPermission localhost:8080 connect, resolve). How can I solve 
 this problem? For your information, I'm now using Windows XP Operating System 
 but I plan to use Linux Fedora Operaing System later. Is there a difference 
 in accessing the application using different operating system? Thank you.
 
 Yours Sincerely,
 TEH

 David Smith wrote:
 Include the port number in your request -- ie 
 http://ipaddress:8080/login.html

 --David

 Teh Noranis Mohd Aris wrote:
 
 Dear All,

 I've tested my applications using http://localhost:8080/login.html in the 
 same computer and it works. However, when I tried to acces my applications 
 using an IP Address in another computer by typing 
 http://ipaddress/login.html, The page cannot be found is displayed. How 
 can I access my applications using IP address? Please help me. Thank you.

 Yours Sincerely,
 TEH 


 -
 Give spam the boot. Take control with tough spam protection
 in the all-new Yahoo! Mail Beta.

 


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 
 -
 Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, 
 news, photos  more. 
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.

   
-
Moody friends. Drama queens. Your life? Nope! - their life, your story.
 Play Sims Stories at Yahoo! Games. 

Cannot Access Tomcat Server Using IP Address

2007-05-20 Thread Teh Noranis Mohd Aris
Dear All,
   
  I've tested my applications using http://localhost:8080/login.html in the 
same computer and it works. However, when I tried to acces my applications 
using an IP Address in another computer by typing http://ipaddress/login.html, 
The page cannot be found is displayed. How can I access my applications using 
IP address? Please help me. Thank you.
   
  Yours Sincerely,
  TEH 

   
-
Give spam the boot. Take control with tough spam protection
in the all-new Yahoo! Mail Beta.

Re: Cannot Access Tomcat Server Using IP Address

2007-05-20 Thread Teh Noranis Mohd Aris
Thank you. It's working now, the application can be accessed but when I type a 
file name to access a file in the server, I got an error 
java.security.AccessControlException:access denied (java.net.SocketPermission 
localhost:8080 connect, resolve). How can I solve this problem? For your 
information, I'm now using Windows XP Operating System but I plan to use Linux 
Fedora Operaing System later. Is there a difference in accessing the 
application using different operating system? Thank you.
   
  Yours Sincerely,
  TEH

David Smith [EMAIL PROTECTED] wrote:
  Include the port number in your request -- ie 
http://ipaddress:8080/login.html

--David

Teh Noranis Mohd Aris wrote:
 Dear All,
 
 I've tested my applications using http://localhost:8080/login.html in the 
 same computer and it works. However, when I tried to acces my applications 
 using an IP Address in another computer by typing 
 http://ipaddress/login.html, The page cannot be found is displayed. How can 
 I access my applications using IP address? Please help me. Thank you.
 
 Yours Sincerely,
 TEH 

 
 -
 Give spam the boot. Take control with tough spam protection
 in the all-new Yahoo! Mail Beta.
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



   
-
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos  more. 

Re: Cannot Access Tomcat Server Using IP Address

2007-05-20 Thread Teh Noranis Mohd Aris
Yes, I can access the login.html interface from a different computer using 
http://IPaddress:8080/login.html but when I tried to access a file, I got the 
mentioned problem displayed in the text area. However, I can access a file if 
I'm using http://localhost:8080/login.html. I'm testing using Windows XP. What 
should I do? Thank you.
   
  TEH 

Omar Eljumaily [EMAIL PROTECTED] wrote:
  I don't understand. Are you able to access login.html from outside your 
server machine? 

The socketpermerission problem you have sounds like a firewall issue or 
a administrator privileges problem not allowing you to accept incoming 
sockets. Are you running with administrator privs on XP?

XP and Linux deal with firewalls and permissions differently. Linux is 
a bit more straight forward in my opinion. You just accept queries on 
8080 and then redirect port 80 if you want to resolve static pages. 
SELinux can be an issue, but is usually simple to solve by tweaking a 
setting.

Teh Noranis Mohd Aris wrote:
 Thank you. It's working now, the application can be accessed but when I type 
 a file name to access a file in the server, I got an error 
 java.security.AccessControlException:access denied 
 (java.net.SocketPermission localhost:8080 connect, resolve). How can I solve 
 this problem? For your information, I'm now using Windows XP Operating System 
 but I plan to use Linux Fedora Operaing System later. Is there a difference 
 in accessing the application using different operating system? Thank you.
 
 Yours Sincerely,
 TEH

 David Smith wrote:
 Include the port number in your request -- ie 
 http://ipaddress:8080/login.html

 --David

 Teh Noranis Mohd Aris wrote:
 
 Dear All,

 I've tested my applications using http://localhost:8080/login.html in the 
 same computer and it works. However, when I tried to acces my applications 
 using an IP Address in another computer by typing 
 http://ipaddress/login.html, The page cannot be found is displayed. How 
 can I access my applications using IP address? Please help me. Thank you.

 Yours Sincerely,
 TEH 


 -
 Give spam the boot. Take control with tough spam protection
 in the all-new Yahoo! Mail Beta.

 


 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 
 -
 Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, 
 news, photos  more. 
 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.

How to read file content from servlet?

2007-05-13 Thread Teh Noranis Mohd Aris
Dear All,
   
  I have an applet that sends data name, score and ScoreFile to a servlet that 
get these data to be saved in a file. My question is, how can I send these data 
from the servlet to the applet (reversed) so that I can use only the data name 
in processing? Please help. Thank you.
   
  Yours Sincerely;
  TEH
   
  The applet is as follows:
   
  URL servletUrl = null;
  URLConnection con;
  String servletName = http://localhost:8080/examples/servlet/ServerSide;;
  try {
  servletUrl = new 
URL(servletName+?name=+name+score=+score+ScoreFile=+ScoreFile);
  con=servletUrl.openConnection();
  con.setUseCaches(false);
  BufferedReader buf = new BufferedReader(new 
InputStreamReader(con.getInputStream())); }
  catch(Exception e) {
  System.out.println(Exception caught...+e); }
   
  The servlet is as follows:
   
  String name = request.getParameter(name);
  int score = Integer.parseInt(request.getParameter(score));
  String ScoreFile = request.getParameter(ScoreFile);
   
  String fileName = C:/temp/+ScoreFile;
FileWriter resultsFile = new FileWriter(fileName,true);
PrintWriter toFile = new PrintWriter(resultsFile,true);
toFile.println(name+ +score);
toFile.close(); 
   
   

   
-
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.

Is it possible to have more than one submit button in a JSP file?

2007-03-28 Thread Teh Noranis Mohd Aris
Dear All, 
   
  I hope all of you can still remember me. I had the problem of writing the 
file content from an applet to a servlet. Now, I'm using JSP and it works. 
However, from JSP code examples, I always see only one submit button to the 
server. I would like my system to have several submit buttons that is connected 
to the server, for example a button for displaying a file from the server and a 
button for saving a file to the server. The file to display and the file to 
save should use the same textarea. How should it be done? If there are any 
source code examples, can anyone please post it to me? Please help! Thank you.
   
  Yours Sincerely,
  TEH NORANIS 

 
-
Need Mail bonding?
Go to the Yahoo! Mail QA for great tips from Yahoo! Answers users.

Re: Is it possible to have more than one submit button in a JSP file?

2007-03-28 Thread Teh Noranis Mohd Aris
Dear All,
   
  Maybe my question is not that clear. What I mean, is that there are 2 buttons 
that read data from the server and write data to the server using one textarea. 
If anyone have the code or come across the code, please e-mail it to me. Thank 
you.
   
  TEH   

Hassan Schroeder [EMAIL PROTECTED] wrote:
  On 3/28/07, Teh Noranis Mohd Aris wrote:

 I would like my system to have several submit buttons

This is a basic HTML question, nothing to do with JSP.

Yes, a form in an HTML document can have multiple submit buttons;
reading the appropriate recommendation is, uh, recommended :-)

HTH,
-- 
Hassan Schroeder  [EMAIL PROTECTED]

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
Don't be flakey. Get Yahoo! Mail for Mobile and 
always stay connected to friends.

Re: File Content Not Saved To Server

2007-03-14 Thread Teh Noranis Mohd Aris
Dear All,
   
  I've already modified my program based on Mr. Christopher's solution but 
thers's still the word null in the file. 
   
  You probably have a null content variable. String.valueOf(null) returns
null, so that's probably what's happening.

  I only declared URL servletUrl = null but now I already commented it.  

  For your information, the purpose of my program is ONLY to save information 
from the client to the server. I don't intend to send back information from the 
server to the client.  
   
  My complete program looks like this now after the suggested modification 
(ClientIdea.java, ServerIdea.java, ClientIdea.html not included):
   
  // C:\jakarta-tomcat-4.1.31\webapps\ROOT\ClientIdea.java
  import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.text.BadLocationException;
import java.net.*;
import java.io.*;
import java.util.*;
   
  public class ClientIdea extends JApplet implements ItemListener, 
ActionListener
{
 
 JPanel panel1, panellabel, panelbutton, paneltext;
 JTextField namefile;
 JButton jbtSave;
 JTextArea textEditor;
 JLabel labelfile;
 
 public void init() 
 {
  
  Container container = getContentPane();
  namefile = new JTextField(10);
  panel1 = new JPanel();
  
  panellabel = new JPanel();
  panelbutton = new JPanel();
  paneltext = new JPanel();
  
  labelfile = new JLabel(File Name);
 
  panellabel.setLayout(new FlowLayout(FlowLayout.LEFT,50,0));
  panellabel.add(labelfile);
  panellabel.add(namefile);
 
  panelbutton.setLayout(new GridLayout(1,1));
  panelbutton.add(jbtSave = new JButton(Save));
 
  textEditor = new JTextArea(18,63);
textEditor.setFont(new Font(monospaced,Font.PLAIN,12));
JScrollPane scrollPane1 = new JScrollPane(textEditor);
Linenumber linenumber1 = new Linenumber ( textEditor );
scrollPane1.setRowHeaderView(linenumber1);
paneltext.add(scrollPane1);
  
  panel1.add(panellabel);
  panel1.add(paneltext);
  panel1.add(panelbutton);
 
  container.add(panel1);
  
  jbtSave.addActionListener (
 new ActionListener() {
  public void actionPerformed (ActionEvent en) {
   savefile();
  }
 }
 );
   
} // end init
 
  public void actionPerformed(ActionEvent ae) 
  {
   
  } // End action perform 
  
  public void itemStateChanged(ItemEvent ie) 
  {
   
  } // End item state changed
  
  
  public void savefile()
  { 
String filename = namefile.getText();
String teditor = textEditor.getText();
   
  //URL servletUrl = null;
 
 URL servletUrl;
 
 URLConnection con;
 
 String servletName = http://localhost:8080/examples/servlet/ServerIdea;
   try
 {
  servletUrl = new URL(servletName + ?filename= + filename);
  con = servletUrl.openConnection();
  con.setDoOutput(true);
  con.setRequestProperty(Content-Type,text/plain;charset=UTF-8);
  con.connect();
 
  OutputStreamWriter out = new 
OutputStreamWriter(con.getOutputStream(),UTF-8); 
  out.write(teditor, 0, teditor.length());
  out.flush();
  out.close();
  
  DataInputStream in = new DataInputStream(con.getInputStream());
  in.close();
 }
 
 catch(Exception e)
 {
  System.out.println(Exception caught...+e);
 }

   } // end savefile
  } // end class ClientIdea
   
  // C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes\ServletIdea.java
  import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
   
  public class ServerIdea extends HttpServlet {
 
 public void doGet(HttpServletRequest req, HttpServletResponse res) throws 
IOException, ServletException
 {   
 String name = req.getParameter(filename);
 String content = req.getParameter(teditor);

 PrintWriter outFile = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(C:/temp/+name)));
 outFile.println(content);
 outFile.close();
 }
 
 public void doPost(HttpServletRequest req, HttpServletResponse res) throws 
IOException, ServletException {
 doGet(req, res);
}  
}
   
  Did I miss out anything? Please help me! Thank you.
   
  Yours Sincerely,
  TEH NORANIS
  
Christopher Schultz [EMAIL PROTECTED] wrote:
  -BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Teh,

Teh Noranis Mohd Aris wrote:
 Now, a file name that was input by the user
 was created BUT the problem is that, when I open the file, the word
 null was written to the file NOT the file content.

You probably have a null content variable. String.valueOf(null) returns
null, so that's probably what's happening.

 The filename
 parameter was sent from the applet to the servlet BUT the file
 content parameter was not sent.

You're going to want to fix that.

 This means that the file content
 parameter does not exist and the servlet did not receive the file
 content parameter!

Sounds about right. If I were you, I would modify my program to do
nothing if there's no file content parameter. (Well, I would actually
use PUT and place

Re: File Content Not Saved To Server

2007-03-03 Thread Teh Noranis Mohd Aris
Dear All,
   
  First, thank you so much for the reply, Mr. Christopher Schultz. In my 
program, I want the servlet to load an applet where I can input the file name 
in a given text field and the file content in a given text area. When the user 
has input the information, I want to POST the file name and its content from 
the applet to the servlet. The servlet will then GET the parameters (file name 
and file content) from the applet and save the file content in C:/temp/ based 
on the file name that has been input. I do not know whether I pass the 
parameters from the applet to the servlet correctly. After I input the file 
name and the file content, 2 files were created by the system:
  1. a file with the name null
  2. a source code file with a file name from the user input with no content at 
all.
   
  The system should only create one file with a file name and the file content 
based on the user input. The main problem is that 2 files were created. One 
question that was asked to me is Why are you saving a file AND serving a page 
in the same servlet? Yes, I'm using the same servlet to save a file and 
serving a page to save files. What is actually the matter with that approach? 
Another question was about What you want is a POST with the content of your 
file in the request body -- NOT in the request parameters. Can you please 
elaborate the statement? How should I actually solve this problem? Please 
explain in detail. I'm really waiting for a prompt reply. Thank you so much.
   
  Yours Sincerely,
  TEH NORANIS

Christopher Schultz [EMAIL PROTECTED] wrote:
  -BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Teh,

Teh Noranis Mohd Aris wrote:
 I want to save a file name and its content to the computer server at 
 directory C:/temp/. I've passed the file name and file content
 parameter from the applet to the servlet. The problem now is that the
 file name is created in the computer server directory but a 'null' is
 included in the file content. Can anyone please help me solve the
 problem why this is happening?

 servletUrl = new URL(servletName + ?filename=+filename+teditor=+teditor);
 con = servletUrl.openConnection();
 con.setUseCaches(false);
 
 BufferedReader buf = new BufferedReader(new 
 InputStreamReader(con.getInputStream()));

This isn't what you want to do. What you want is a POST with the content
of your file in the request body -- NOT in the request parameters.

That isn't to say that your attempt won't work... it's just that there
are many limitations on passing information through a URL (such as any
maximum URL length limits set by your web server).

 HttpSession session = req.getSession();
 PrintWriter out = res.getWriter();
 
 out.println();
 out.println();
 out.println();
 out.println(Save File To Server);

 ...

This is a very odd way to do things. Why are you saving a file AND
serving a page to save files in the same servlet?

 String name = req.getParameter(filename);
 String content = req.getParameter(teditor);
 
 String nameFile = C:/temp/+name;
 FileWriter resultsFile = new FileWriter(nameFile,true);
 PrintWriter toFile = new PrintWriter(resultsFile,true);
 toFile.println(content);
 toFile.close(); 

So, do you get a file in C:\TEMP\whatever? If so, what is the content of
the file. You said a null... do you mean a 0 byte file? Or the word
null?

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF6KD09CaO5/Lv0PARAph4AJ0RFetzCrvK7kylCLOjfz0s2lNtngCfVgSg
06XYsRJpi0Bn/mEjBsAnp4I=
=6KXD
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
Access over 1 million songs - Yahoo! Music Unlimited.

Re: File Content Not Saved To Server

2007-03-03 Thread Teh Noranis Mohd Aris
Dear All,
   
  Thank you so much for the explanation, Mr. Christopher Schultz. I understand 
that by just using a file input type, I can upload a file directly. In fact, 
I already construct the program and it is already working. However, I choose to 
use applet to get the advantage of Java GUI programming, which is event-driven. 
Actually, the save file module is only part of the system. I'm going to try 
what has been suggested and I will get to you soon. Thank you so much. 
   
  Yours Sincerely,
  TEH NORANIS  

Christopher Schultz [EMAIL PROTECTED] wrote:
  -BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Teh,

Teh Noranis Mohd Aris wrote:
 In
 my program, I want the servlet to load an applet where I can input
 the file name in a given text field and the file content in a given
 text area.

Just out of curiosity, why do you want an applet to do this when you can
just use a file input type and upload a file directly?

 When the user has input the information, I want to POST
 the file name and its content from the applet to the servlet.

You are not using a POST. You are using a GET. If you want to use a
POST, you will have to write your file content to the request body,
instead of putting it into a URL parameter.

You had something like this:

String url = http://.../servlet?filename=[name]content=[contents];;

URLConnection conn = new URL(url).openConnection();
conn.connect();
conn.close();

Instead, you should do something like this:

String url = http://...servlet?filename=[name];;
URLConnection conn = new URL(url).openConnection();
conn.setDoOutput(true);
conn.setHeader(Content-Length, contents.length());
conn.connect();

OutputStream out = conn.getOutputStream();
out.write(contents);
out.flush();
out.close();

conn.close();

This will put the contents of your file into the request body, instead
of in the URL parameters.

 I do not know whether I pass the
 parameters from the applet to the servlet correctly.

To check that the parameters are correct, put something like this into
your servlet code:

System.out.println(param[filename] = 
+ request.getParameter(filename));

Also, you might want to print out the fill path of the file you are
trying to create. This really ought to do it:

File target = new File(C:\\TEMP, filename);

FileOutputStream out = new FileOutputStream(target);
out.write(contents);
out.flush();
out.close();

 After I input
 the file name and the file content, 2 files were created by the
 system: 1. a file with the name null 2. a source code file with a
 file name from the user input with no content at all.

I'm not sure how that extra file is being created. Your code only had a
single open call. Is it possible that null was created from an old
copy of the code, and you just forgot to delete the file?

Finally, don't use a FileWriter unless you know that you are dealing
with text. Otherwise, binary files will be corrupted. I'm not sure if
that matters to you, but creating a servlet that handles any type of
file will be more useful than one that only handles text.

 Yes, I'm using
 the same servlet to save a file and serving a page to save files.
 What is actually the matter with that approach?

It just seems that the save file servlet should do nothing but save a
file. Why have this servlet return any content at all? If I were writing
this system, I would have the following files:

applet.html (contains element to serve the applet)
SaveFileServlet (saves files, as discussed)

When you want to display the applet, just display applet.html.
Otherwise, your SaveFileServlet will write to a file called null every
time you try to display the page (that's probably where your null file
is coming from).

Only call the SaveFileServlet when you actually want to save data.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF6b3n9CaO5/Lv0PARApg9AKCHsXSGif7v69laYl4u1DHmGvRrHACbB7cz
z2uU32oMdoJKcvL1/9EXf6A=
=sF79
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

File Content Not Saved To Server

2007-03-01 Thread Teh Noranis Mohd Aris
Dear All, 
   
  I want to save a file name and its content to the computer server at 
directory C:/temp/. I've passed the file name and file content parameter from 
the applet to the servlet. The problem now is that the file name is created in 
the computer server directory but a 'null' is included in the file content. Can 
anyone please help me solve the problem why this is happening? 
  Thank you so much.
   
  The applet is as follows:
   
  // AppletSave.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.text.BadLocationException;
import java.net.*;
import java.io.*;
import java.util.*;
  public class AppletSave extends JApplet implements ItemListener, 
ActionListener
{
 
 JPanel panel1, panellabel, panelbutton, paneltext;
 
 JTextField namefile;
 
 JButton jbtSave;
 
 JTextArea textEditor;
 
 JLabel labelfile;
 
 public void init() 
 {
  
  Container container = getContentPane();
   
  namefile = new JTextField(10);
  
  panel1 = new JPanel();
  
  panellabel = new JPanel();
  panelbutton = new JPanel();
  paneltext = new JPanel();
  
  labelfile = new JLabel(File Name);
 
  panellabel.setLayout(new FlowLayout(FlowLayout.LEFT,50,0));
  panellabel.add(labelfile);
  panellabel.add(namefile);
 
  panelbutton.setLayout(new GridLayout(1,1));
  
  panelbutton.add(jbtSave = new JButton(Save));
  
  textEditor = new JTextArea(18,63);
textEditor.setFont(new Font(monospaced,Font.PLAIN,12));
JScrollPane scrollPane1 = new JScrollPane(textEditor);
Linenumber linenumber1 = new Linenumber ( textEditor );
scrollPane1.setRowHeaderView(linenumber1);
paneltext.add(scrollPane1);
   
  panel1.add(panellabel);
  panel1.add(paneltext);
  panel1.add(panelbutton);
 
  container.add(panel1);
  
  jbtSave.addActionListener (
 new ActionListener() {
  public void actionPerformed (ActionEvent en) {
   savefile();
  }
 }
 );
   
} // end init
 
  public void actionPerformed(ActionEvent ae) 
  {
   
  } // End action perform 
  
  public void itemStateChanged(ItemEvent ie) 
  {
   
  } // End item state changed
  
  
  public void savefile()
  { 
  
 String filename = namefile.getText();
 String teditor = textEditor.getText(); 
   URL servletUrl = null;
 
 URLConnection con;
 
 String servletName = http://localhost:8080/examples/servlet/ServletIde;;
   try
 {
  servletUrl = new URL(servletName + ?filename=+filename+teditor=+teditor);
  con = servletUrl.openConnection();
  con.setUseCaches(false);
 
  BufferedReader buf = new BufferedReader(new 
InputStreamReader(con.getInputStream()));
 }
 
 catch(Exception e)
 {
  System.out.println(Exception caught...+e);
 }

   } // end savefile
  } // end class AppletSave
   
  The servlet is as follows:
   
  import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
  public class ServletSave extends HttpServlet {
 
 public void doGet(HttpServletRequest req, HttpServletResponse res) throws 
IOException, ServletException
 {
  
  HttpSession session = req.getSession();
  PrintWriter out = res.getWriter();
  
  out.println(html);
  out.println(head);
  out.println(titleLogin/title);
  out.println(centerh2Save File To Server/h2);
  out.println(applet width=500 height=400);
  out.println(name=\AppletSave\);
  out.println(codebase=\/\);
  out.println(code=\AppletSave\);
  out.println(param name=\servlet\ value=\ +
  req.getRequestURI() + \);
  out.println(param name=\id\ value=\ +
  session.getId() + \);
  out.println(/applet);
  out.println(/center/body/html); 
 
 
 String name = req.getParameter(filename);
 String content = req.getParameter(teditor);
 
 String nameFile = C:/temp/+name;
 FileWriter resultsFile = new FileWriter(nameFile,true);
 PrintWriter toFile = new PrintWriter(resultsFile,true);
 toFile.println(content);
 toFile.close();   
 }
 
} 
   
  Yours Sincerely,
  TEH NORANIS

 
-
The fish are biting.
 Get more visitors on your site using Yahoo! Search Marketing.

Cannot save file to Apache Tomcat server

2007-02-15 Thread Teh Noranis Mohd Aris
Dear all,
   
  I really hope that someone can help me out. I have an error-free applet and 
servlet. When I type http://localhost:8080/examples/servlet/ServletIdea, an 
applet is loaded. From the applet, I type the file name in a text field and the 
file content in a text area. I want the file content to be saved in the 
specified file name. The problem is that the file cannot be saved to the 
server. I put ServletIdea.java in 
C:/jakarta-tomcat-4.1.31/webapps/examples/WEB-INF/classes. I put IdeaTool.java 
in C:/jakarta-tomcat-4.1.31/webapps/ROOT. The programs are as follows:
   
  //ServletIdea.java
  import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
   
  public class ServletIdea extends HttpServlet {
 
 public void doGet(HttpServletRequest req, HttpServletResponse res) throws 
IOException, ServletException
 {
  
  HttpSession session = req.getSession();
  PrintWriter out = res.getWriter();
  
  out.println(html);
  out.println(head);
  out.println(titleLogin/title);
  out.println(centerh2Servlet Idea/h2);
  out.println(applet width=500 height=400);
  out.println(name=\IdeaTool\);
  out.println(codebase=\/\);
  out.println(code=\IdeaTool\);
  out.println(param name=\servlet\ value=\ +
  req.getRequestURI() + \);
 out.println(param name=\id\ value=\ +
 session.getId() + \);
 out.println(/applet);
 out.println(/center/body/html); 
   
 }
 
 public void doPost(HttpServletRequest req, HttpServletResponse res) throws 
IOException, ServletException
 {
  res.setContentType(text/html);
  DataInputStream in = new DataInputStream(req.getInputStream());
  PrintWriter out = res.getWriter();
  
  String filename = in.readUTF();
 String filecontent = in.readUTF();
 
 if (filename != null || filecontent != null) {
  out.println(filename=+filename+PNext);
  out.println(filecontent=+filecontent);
 }
 
 else{
  out.println(requestparams.no-params);  
 }
 out.println(P);
 try {
  PrintWriter outFile = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(C://+filename)));
  outFile.println(filecontent);
  outFile.close();
  }
  catch (FileNotFoundException e){
   out.println(Cannot open file +filename);
  }
catch (IOException e) {
 out.println(write data file IO exception);
}
out.close();
  
 }
 
}
   
  // IdeaTool.java
// Java core pakages
import java.awt.*;
import java.awt.event.*;
// Java extension packages
import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.text.BadLocationException;
import java.net.*;
import java.io.*;
import java.util.*;
   
  public class IdeaTool extends JApplet implements ItemListener, ActionListener 
{
 
 JPanel panel1, panellabel, panelbutton, paneltext;
 
 JTextField namefile;
 
 JButton jbtSave;
 
 JTextArea textarea1;
 
JLabel labelfile;
 
 String line;
 
 String codeBase, servlet, sessionId;
 
 public void init() {
  
  codeBase =  + getCodeBase();
  servlet = getParameter(servlet);
  
  if (servlet != null)
  {
   if (servlet.startsWith(/)  codeBase.endsWith(/))
   {
codeBase = codeBase.substring(0, codeBase.length() - 1);
   }
  }
  
  sessionId = getParameter(id);
  
  Container container = getContentPane();
   
  namefile = new JTextField(20);

  panel1 = new JPanel();
  panellabel = new JPanel();
  panelbutton = new JPanel();
  paneltext = new JPanel();
  
  labelfile = new JLabel(File Name);
  
  panellabel.setLayout(new FlowLayout(FlowLayout.LEFT,90,0));
  panellabel.add(labelfile);
  panellabel.add(namefile);
  
  panelbutton.setLayout(new GridLayout(1,1));
  
  panelbutton.add(jbtSave = new JButton(Save));
  jbtSave.addActionListener (
 new ActionListener() {
  public void actionPerformed (ActionEvent en) {
   savefile();
  }
 }
 );
 
  textarea1 = new JTextArea(18,63);
textarea1.setFont(new Font(monospaced,Font.PLAIN,12));
JScrollPane scrollPane1 = new JScrollPane(textarea1);
Linenumber linenumber1 = new Linenumber ( textarea1 );
scrollPane1.setRowHeaderView(linenumber1);
paneltext.add(scrollPane1);
  
  panel1.add(panelbutton);
  panel1.add(panellabel);
  panel1.add(paneltext);
  
  container.add(panel1);
   
 } // end init
 
  public void actionPerformed(ActionEvent ae) {
  } // End action perform 
  
  public void itemStateChanged(ItemEvent ie) {
  } // End item state changed
  
public void savefile(){
 
String filename = namefile.getText();
 String filecontent = textarea1.getText();
  
 try 
 {
 java.net.URL url = new java.net.URL(codeBase + servlet);
java.net.URLConnection con = url.openConnection();

con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);

ByteArrayOutputStream byteOut = new ByteArrayOutputStream();

DataOutputStream out = new DataOutputStream(byteOut);

   

Applet to JSP communication

2007-02-12 Thread Teh Noranis Mohd Aris
Dear all,
   
  How can my applet communicate with JSP using POST and GET? I have an applet 
with a Save button to save data in a file at Apache Tomcat server. The applet 
also contain JTextField to input the file name and JTextArea to input the text 
to be saved. How can the applet and JSP communicate? Can anyone please e-mail 
me the source code? Thank you so much.
   
  Yours Sincerely,
  TEH NORANIS

 
-
Don't get soaked.  Take a quick peak at the forecast 
 with theYahoo! Search weather shortcut.

Servlet/JSP source code to save data in a file

2007-02-10 Thread Teh Noranis Mohd Aris
Dear all,
   
  Does anyone have the Servlet/JSP source code to save data in a file that will 
be located in the server? I need the source code very urgently. I have my own 
version but it is not working. Please help me! Thank you.
   
   
  Yours Sincerely,
  TEH NORANIS 

 
-
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.

Why applets cannot link to next page in a servlet?

2007-01-19 Thread Teh Noranis Mohd Aris
Dear All,

I put my applet and servlet in a directory (using
package statement in the java file) which I defined.
When I called the servlet in a web browser, the first
page of the applet was displayed. But when I login a
valid user name and password, the applet cannot link
to the next page which is defined in a servlet. 

Then, without defining the applet and servlet using
package, I tried to put the applet in:
C:\jakarta-tomcat-4.1.31\webapps\ROOT\ and the servlet
in:
C:\jakarta-tomcat-4.1.31\webapps\examples\WEB-INF\classes
and it works fine!

Can anyone please tell me why the applet CANNOT link
to the next page if I'm using package but it CAN link
to the next page without using package? How can I fix
this problem because I really want to organize my
files using package. Please help me! Thank you.

Yours Sincerely,
TEH NORANIS   


 

Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Applet does not send request to servlet

2007-01-17 Thread Teh Noranis Mohd Aris
 user = username.getText();
String pw = password.getText();

boolean valid = false;
try
{
 valid = validate(user, pw);
}
catch (Exception ex)
{
 ex.printStackTrace();
}

if (!valid)
{
 message.setText(Invalid user - please try again);
}
else
{
 try
 {
  URL url = new URL(nextDoc);
  System.out.println(showing  + url);
  getAppletContext().showDocument(url);
 }
 catch (Exception ex)
 {
  message.setText(Invalid document:  + nextDoc);
  ex.printStackTrace();
 }
}
   }
  }
  return false;  
 }
 protected boolean validate(String user, String pw) throws Exception
 {
  boolean valid = false;
  
  java.net.URL url = new java.net.URL(codeBase + servlet);
  
  java.net.URLConnection con = url.openConnection();
  
  con.setUseCaches(false);
  con.setDoOutput(true);
  con.setDoInput(true);
  
  ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
  
  DataOutputStream out = new DataOutputStream(byteOut);
  
  out.writeUTF(sessionId);
  
  out.writeUTF(user);
  out.writeUTF(pw);
  
  out.flush();
  
  byte buf[] = byteOut.toByteArray();
  
  con.setRequestProperty(Content-type, application/octet-stream);
  
  con.setRequestProperty(Content-length,  + buf.length);
  
  DataOutputStream dataOut = new DataOutputStream(con.getOutputStream());
  dataOut.write(buf);
  
  dataOut.flush();
  dataOut.close();
  
  DataInputStream in = new DataInputStream(con.getInputStream());
  
  valid = in.readBoolean();
  System.out.println(valid user= + valid);
  
  if (valid)
  {
   nextDoc = in.readUTF();
   System.out.println(next document= + nextDoc);
  }
  
  in.close();
  return valid;
 } 
}

   
  TEH NORANIS
  
Zack Grafton [EMAIL PROTECTED] wrote:
  I would have to agree with the attachment capability of this mailing list.

Zack

Andre Prasetya wrote:
 i think attachments are disabled...

 On 1/17/07, Teh Noranis Mohd Aris wrote:

 Hi,

 I already solve the problem of loading my applet in the web browser. 
 Thank
 you to all. Now, I'm having the problem to send request from the 
 applet to
 the servlet. Attached is the AppletLogin.java (the servlet which I 
 put in
 package myapp) and LoginApplet.java (the applet which I put in package
 myapp.applets). I use http://localhost:8080/myapp/AppletLogin to access
 the applet. The same username and password input should link to 
 Welcome to
 our site, More cool stuff coming soon but I got the Invalid user -
 please try again message. I tried to modify the codeBase variable in 
 the
 init() method of the applet but could not link to the next page. I think
 that the applet cannot access the servlet in package myapp. The attached
 programs are only short programs in a book. I just want to organize the
 programs in my own directory. Does anyone have any other ideas why 
 this is
 happening? Please help me! Thank you in advance.

 Yours Sincerely,
 TEH NORANIS

 --
 Need a quick answer? Get one in minutes from people who know. Ask your
 question on Yahoo! 
 Answers. 




 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.

Re: Applet does not send request to servlet

2007-01-17 Thread Teh Noranis Mohd Aris
Hello,

I've been working out the applet program since last
night but still could not get it correct. I think that
the codeBase variable path that was initialised in the
applet program is not correct. I put the
LoginApplet.class in
C:\jakarta-tomcat-4.1.31\webapps\myapp\applets. It's
just a matter of writing the codeBase variable the
correct way. Can anyone please give me any
suggestions? Please Help Me! Hoping for a reply. Thank
you.

TEH NORANIS   
--- Teh Noranis Mohd Aris [EMAIL PROTECTED]
wrote:

 Hi,

   I'm sorry, I didn't realize about the attachment
 capability for this mailing list. However here are
 the programs that I attached previously. Hope
 someone can help me out. Thank you.

   1. THE SERVLET PROGRAM:

   package myapp;
   import javax.servlet.*;
 import javax.servlet.http.*;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Hashtable;
   public class AppletLogin extends HttpServlet
 {
  public static String USER_KEY =
 ServletLogin.user;
  
  static Hashtable crossRef = new Hashtable();
  
  public void doGet(HttpServletRequest req,
 HttpServletResponse resp)
throws ServletException, java.io.IOException
{
 resp.setContentType(text/html);
 
 PrintWriter out = resp.getWriter();
 
 resp.setHeader(Expires, Tues, 01 Jan 1980
 00:00:00 GMT);
 
 HttpSession session = req.getSession();
 String user = (String)
 session.getAttribute(USER_KEY);
 
 if (user == null)
 {
 user = (String)
 crossRef.get(session.getId());
 
 if (user != null)
 {
  session.setAttribute(USER_KEY, user);
  crossRef.remove(session.getId());
 }
 
  
 }

if (user == null)
{
 login(out, req, resp);
 return;
}

out.println(html);
out.println(head);
out.println(titleWelcome/title);
out.println(/head);
out.println(body);
out.println(centerh2Welcome to our
 site!/h2);
out.println(br);
out.println(More cool stuff coming soon...);
out.println(/center);

out.println(/body);
out.println(/html);
out.flush(); 
  }
  
  public void doPost(HttpServletRequest req,
 HttpServletResponse resp)
throws ServletException, java.io.IOException
  {
   DataInputStream in = new
 DataInputStream(req.getInputStream());
   
   resp.setContentType(application/octet-stream);
   
   ByteArrayOutputStream byteOut = new
 ByteArrayOutputStream();
   
   DataOutputStream out = new
 DataOutputStream(byteOut);
   
   String sessionId = in.readUTF();
   
   String user = in.readUTF();
   String password = in.readUTF();
 
   if (!validUser(user, password))
   {
out.writeBoolean(false);
   }
   else
   {
crossRef.put(sessionId, user);
out.writeBoolean(true);

String nextPage = req.getScheme() + :// +

req.getServerName() + : +
req.getServerPort() +
req.getRequestURI();

out.writeUTF(nextPage);
   }
   
   out.flush();
   
   byte[] buf = byteOut.toByteArray();
   
   resp.setContentLength(buf.length);
   
   ServletOutputStream servletOut =
 resp.getOutputStream();
   
   servletOut.write(buf);
   servletOut.close();
  }
   
   protected void login (PrintWriter out, 
 HttpServletRequest req, 
 HttpServletResponse resp)
 throws java.io.IOException
   {
HttpSession session = req.getSession();

out.println(html);
out.println(head);
out.println(titleLogin/title);
out.println(centerh2Welcome! Please
 login/h2);
out.println(applet width=300 height=120);
out.println(name=\LoginApplet\);
out.println(codebase=\ + req.getContextPath()
 + /applets/\);
   
 out.println(code=\webide.applets.LoginApplet\);
out.println(param name=\servlet\ value=\ +
req.getRequestURI() + \);
   out.println(param name=\id\ value=\ +
   session.getId() + \);
   out.println(/applet);
   out.println(/center/body/html);   
  
   }
   
   protected boolean validUser(String username,
 String password)
   {
boolean valid = false;

if ((username != null)  (username.length() 
 0))
{
 valid = username.equals(password);
}

return valid;

   } 
  
 }

   2. THE APPLET PROGRAM:

   package myapp.applets;
   import java.applet.*;
 import java.awt.*;
 import java.io.*;
 import java.net.*;
   public class LoginApplet extends Applet 
 {
  TextField username;
  TextField password;
  Label message;
  Button login;
  String codeBase;
  String servlet;
  String nextDoc;
  String sessionId;
  
  public void init() 
  {
   codeBase =  + getCodeBase();
   servlet = getParameter(servlet);
   
   if (servlet != null)
   {
if (servlet.startsWith(/) 
codeBase.endsWith(/))
{
 codeBase =
 codeBase.substring(0

Re: Cannot load applet on web browser

2007-01-16 Thread Teh Noranis Mohd Aris
Thank you for the reply. I already created the LoginApplet.html and embed the 
LoginApplet.class. Where should I put the files in the tomcat directory? Where 
should I put the JSP files? How about the WEB-INF file? Please help me! I'm 
really short of time! Thank you so much.
   
  Yours Sincerely,
  TEH NORANIS

Zack Grafton [EMAIL PROTECTED] wrote:
  I totally agree with Vacuum Joe on his point at getting familiar with 
Tomcat. As well, I believe the applet tag is considered deprecated with 
most of the newer versions of Java. There is a program in the bin 
folder under your Java installation directory called HtmlConverter. 
This program will help you replace the applet tag with the appropriate 
object tags.

Good Luck!

Zack

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

Re: Cannot load applet on web browser

2007-01-16 Thread Teh Noranis Mohd Aris
Yes, you are correct Mr. David Smith, I was just about to tell this matter. I 
did not put the LoginApplet.class in the WEB-INF. I choose to use html in the 
servlet because I would like to upgrade the previous system that was written in 
cgi. For the moment, I plan to use servlet and will upgrade to JSP later. I'm 
really stressed developing programs using Tomcat because I'm running out of 
time! I very much hope that tomcat users can help me out. Thank you so much, 
David. I will try out your suggestion tomorrow because I'm having a headache 
now. I will inform you tomorrow. Thank you also to all who contributed.
   
  Yours Sincerely,
  TEH NORANIS  

David Smith [EMAIL PROTECTED] wrote:
  I reread the original post and I don't think you are all that far off in
your setup. I'll recap a little here just to be sure I'm reading it right:

Servlet is located at WEB-INF/classes/AppletLogin.class (I would
recommend this be in an official package)
Applet is located at myapp/applets/LoginApplet.class (note for all that
are following this thread, this is not in the WEB-INF dir)


Here's the result of your servlet code:




Welcome! Please login


  name=LoginApplet
codebase=/applets
code=LoginApplet






I notice straight off there is no closing head tag or opening body tag. 
These are big html errors and your lucky the browser is even attempting
to display it as well as it has. Additionally, I believe your applet
params are incorrect resulting in your browser not being able to
retreive the applet. Consider composing the code and codebase attribute as:

out.println( code=\LoginApplet.class\ ) ;
out.println( codebase=\ + req.getContextPath() + /applets ) ;

--David

Teh Noranis Mohd Aris wrote:

Thank you for the reply. I already created the LoginApplet.html and embed the 
LoginApplet.class. Where should I put the files in the tomcat directory? Where 
should I put the JSP files? How about the WEB-INF file? Please help me! I'm 
really short of time! Thank you so much.
 
 Yours Sincerely,
 TEH NORANIS

Zack Grafton wrote:
 I totally agree with Vacuum Joe on his point at getting familiar with 
Tomcat. As well, I believe the applet tag is considered deprecated with 
most of the newer versions of Java. There is a program in the bin 
folder under your Java installation directory called HtmlConverter. 
This program will help you replace the applet tag with the appropriate 
object tags.

Good Luck!

Zack

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
 



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
-
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.

Applet does not send request to servlet

2007-01-16 Thread Teh Noranis Mohd Aris
Hi,
   
  I already solve the problem of loading my applet in the web browser. Thank 
you to all. Now, I'm having the problem to send request from the applet to the 
servlet. Attached is the AppletLogin.java (the servlet which I put in package 
myapp) and LoginApplet.java (the applet which I put in package myapp.applets). 
I use http://localhost:8080/myapp/AppletLogin to access the applet. The same 
username and password input should link to Welcome to our site, More cool 
stuff coming soon but I got the Invalid user - please try again message. I 
tried to modify the codeBase variable in the init() method of the applet but 
could not link to the next page. I think that the applet cannot access the 
servlet in package myapp. The attached programs are only short programs in a 
book. I just want to organize the programs in my own directory. Does anyone 
have any other ideas why this is happening? Please help me! Thank you in 
advance.
   
  Yours Sincerely,
  TEH NORANIS  

 
-
Need a quick answer? Get one in minutes from people who know. Ask your question 
on Yahoo! Answers.-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Cannot load applet on web browser

2007-01-15 Thread Teh Noranis Mohd Aris
Hi,
   
  I have created programs under the following directory:
   
  servlet program:
  jakarta-tomcat-4.1.31/webapps/myapp/WEB-INF/classes/AppletLogin.class
   
  applet program:
  jakarta-tomcat-4.1.31/webapps/myapp/applets/LoginApplet.class
   
  deployment descriptor:
  myapp/WEB-INF/web.xml
   
  The servlet creates an HTML page that will present an applet that gathers the 
username and password. This servlet will also validate the input and redirect 
the applet as necessary. Following is part of the servlet code:
   
  .
  .
  .
  out.println(html);
out.println(head);
out.println(titleLogin/title);
out.println(centerh2Welcome! Please login/h2);
out.println(applet width=500 height=500);
out.println(name=\LoginApplet\);
out.println(codebase=\/applets\);
out.println(code=\LoginApplet\);
out.println(param name=\servlet\ value=\ +
req.getRequestURI() + \);
out.println(param name=\id\ value=\ +
session.getId() + \);
out.println(/applet);
out.println(/center/body/html);  
  .
  .
  .
  The text Welcome! Please login appears in the web browser but the applet is 
not loaded in the web browser giving a message Applet LoginApplet notinited. I 
think that there is something wrong with the way I write the codebase and code 
statement as above. I tried many times modifying the codebase and code 
statement but still the LoginApplet cannot be loaded. Can anyone tell me the 
correct way to write the codebase and code statement? Please help me! Thank you.
   
  Yours Sincerely,
  TEH NORANIS 

 
-
8:00? 8:25? 8:40?  Find a flick in no time
 with theYahoo! Search movie showtime shortcut.

Problem with Applet-to-Servlet Programs

2007-01-14 Thread Teh Noranis Mohd Aris
Hi,
  I'm doing applet-to-servlet programs. I've put the applet in directory 
c:\jakarta-tomcat-4.1.31\webapps\ROOT\application\LoginApplet. I've put the 
servlet in directory 
c:\jakarta-tomcat-4.1.31\webapps\application\WEB-INF\classes\AppletLogin. When 
I run it in the web browser using 
http://localhost:8080/application/servlet/AppletLogin, I got the following 
error:
   
  HTTP Status 404 - application/AppletLogin
  type Status report
  message /application/AppletLogin
  description The requested resource (/application/AppletLogin) is not 
available.
   
  Where did it go wrong? How can I solve the problem? I've attached the applet 
and servlet programs. Please help me! Thank you.
   
  Yours Sincerely,
  TEH NORANIS  

 
-
Never Miss an Email
Stay connected with Yahoo! Mail on your mobile. Get started!-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Please Help!Tomcat Not Running on Linux Fedora

2006-10-31 Thread Teh Noranis Mohd Aris
Dear All,
   
  I'm very new to Linux Fedora and not quite familiar to the commands. I'm 
using Fedora Core 2.6.9-1.667. I've already installed j2sdk1.4.2_10 and 
jakarta-tomcat-4.1.31 on my computer. Unfortunately, when I tried to execute 
Tomcat in the bin directory by typing ./startup.sh the following message 
appeared:
   
  The JAVA_HOME environment variable is not defined
  This environment variable is needed to run this program
   
  I've used the vi .bash_profile command to set the PATH, JAVA_HOME and 
CATALINA_HOME as follows:
   
  # .bash_profile
  .
  .
  .
  
PATH=$PATH:$HOME/bin;/j2sdk1.4.2_10/bin;/jakarta-tomcat-4.1.31/common/lib/servlet.jar
  JAVA_HOME=/j2sdk1.4.2_10
  CATALINA_HOME=/jakarta-tomcat-4.1.31
  .
  .
  .
  I tried to run a java program using javac and it worked, though I'm not sure 
how to modify the system PATH variable. I tried to type echo $PATH but did not 
find the system PATH variable. Are my steps correct? Did I miss anything? 
   
  Can anyone please explain to me in the most simple way how to solve the 
problem? To those who have already made Tomcat run on Linux Fedora, please help 
me! Waiting to hear from you soon. Thank you.
   
  Yours Sincerely,
  TEH   
   

 
-
Access over 1 million songs - Yahoo! Music Unlimited Try it today.

Re: Please Help! Error in using Packages

2005-12-28 Thread Teh Noranis Mohd Aris
Actually, it's only a small matter. I accessed the url
from the browser by not following the correct path as
in the url-pattern in web.xml file. That's why I got
the error message 404 where the path is not available.

TEH 

--- KJ R [EMAIL PROTECTED] wrote:

 Usually, when you solve a problem, it's helpful to
 post what the solution was, even if it was something
 silly, it could possibly help someone else.
 
 K
 
 --- Teh Noranis Mohd Aris [EMAIL PROTECTED]
 wrote:
 
  Dear all,
  I've already solve the problem. Thanks to all who
  had
  contributed.
  
  TEH
  
  
  --- Prasad [EMAIL PROTECTED] wrote:
  
   Teh,
   
   The web.xml looks fine to me.  Can  you confirm
  that
   you war file is 
   packaged correctly i.e
   its created with proper packages structure and
   dir/file names.
   
   Also, I was wondering why are you being asked to
   (explicitly) create a 
   context element in server.xml. Is it a TC v4.x
   requirement ?
   I have used TC 3,4 and 5 but never was I
 required
  to
   explicitly create a 
   context entry in server.xml for any webapp.
   
   I used more of a traditional way of dropping a
 war
   file into webapps/ 
   and re-starting the container and it has been
   working
   fine for me so far.
   
   Experts, any thoughts on this one ?
   
   Teh, if you are sure that the deployed WAR is
 sane
   then we should wait 
   for experts to provide an answer.
   
   -Prasad.
   
   Teh Noranis Mohd Aris wrote:
   
   The web.xml looks like this:
   
   ?xml version=1.0 encoding=ISO-8859-1?
   
   !DOCTYPE web-app
   PUBLIC -//Sun Microsystems, Inc.//DTD Web
   Application 2.3//EN
  
   http://java.sun.com/j2ee/dtds/web-app_2_3.dtd;
   
   web-app
   
 servlet
   servlet-nameMyFirstServlet/servlet-name
  
  
 

servlet-classcom.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet/servlet-class
 /servlet
   
 servlet-mapping
   servlet-nameMyFirstServlet/servlet-name
   url-pattern
 /MyFirstServlet
   /url-pattern
 /servlet-mapping
   
   /web-app
   
   I placed the web.xml in
   c:\jakarta-tomcat-4.1.31\webapps\ch03\WEB-INF
   directory.
   
   How about the server.xml file in
   c:\jakarta-tomcat-4.1.31\conf directory? The
   original
   file looks like this:
   
   .
   .
   .
   !-- Tomcat Examples Context --
   Context path=/examples
   docBase=examples
   debug=0
reloadable=true
   crossContext=true
 Logger
  
 className=org.apache.catalina.logger.FileLogger
   
   prefix=localhost_examples_log.
   suffix=.txt
  timestamp=true/
 Ejb   name=ejb/EmplRecord
   type=Entity
   
   home=com.wombat.empl.EmployeeRecordHome
 
   remote=com.wombat.empl.EmployeeRecord/
   .
   .
   .
   
   Should I replace Context path=/examples to
   Context
   path=ch03 and docBase=examples to
   docBase=myfirstwebapp (the war file for
   myfirstwebapp in the
   c:\jakarta-tomcat-4.1.31\webapps\ch03
 directory)?
   Thanks.
   
   TEH  
   
   --- Prasad [EMAIL PROTECTED] wrote:
   
 
   
   Can you post your web.xml. I think I can help
  you
   with this but only 
   after looking at your web.xml.
   I think the problem is with servlet and
   servlet-mapping in your 
   web.xml. Moreover as David said, you can find
  all
   the information in the 
   Docs.
   -Prasad.
   
   
   
   
  
 

-
 
   
   To unsubscribe, e-mail:
   [EMAIL PROTECTED]
   For additional commands, e-mail:
   [EMAIL PROTECTED]
   
   
   
   
   
   
  
 
 __
   Do You Yahoo!?
   Tired of spam?  Yahoo! Mail has the best spam
   protection around 
   http://mail.yahoo.com 
   
  
 

-
   To unsubscribe, e-mail:
   [EMAIL PROTECTED]
   For additional commands, e-mail:
   [EMAIL PROTECTED]
   
   
 
   
   
   
  
 

-
   To unsubscribe, e-mail:
   [EMAIL PROTECTED]
   For additional commands, e-mail:
   [EMAIL PROTECTED]
   
   
  
  
  
  
  
  __ 
 
=== message truncated ===




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Please Help! Error in using Packages

2005-12-20 Thread Teh Noranis Mohd Aris
The web.xml looks like this:

?xml version=1.0 encoding=ISO-8859-1?

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN
http://java.sun.com/j2ee/dtds/web-app_2_3.dtd;

web-app

  servlet
servlet-nameMyFirstServlet/servlet-name
   
servlet-classcom.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet/servlet-class
  /servlet

  servlet-mapping
servlet-nameMyFirstServlet/servlet-name
url-pattern
  /MyFirstServlet
/url-pattern
  /servlet-mapping

/web-app

I placed the web.xml in
c:\jakarta-tomcat-4.1.31\webapps\ch03\WEB-INF
directory.

How about the server.xml file in
c:\jakarta-tomcat-4.1.31\conf directory? The original
file looks like this:

.
.
.
!-- Tomcat Examples Context --
Context path=/examples docBase=examples
debug=0
 reloadable=true
crossContext=true
  Logger
className=org.apache.catalina.logger.FileLogger
 prefix=localhost_examples_log.
suffix=.txt
  timestamp=true/
  Ejb   name=ejb/EmplRecord type=Entity

home=com.wombat.empl.EmployeeRecordHome
  
remote=com.wombat.empl.EmployeeRecord/
.
.
.

Should I replace Context path=/examples to Context
path=ch03 and docBase=examples to
docBase=myfirstwebapp (the war file for
myfirstwebapp in the
c:\jakarta-tomcat-4.1.31\webapps\ch03 directory)?
Thanks.

TEH  

--- Prasad [EMAIL PROTECTED] wrote:

 Can you post your web.xml. I think I can help you
 with this but only 
 after looking at your web.xml.
 I think the problem is with servlet and
 servlet-mapping in your 
 web.xml. Moreover as David said, you can find all
 the information in the 
 Docs.
 -Prasad.
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Please Help! Error in using Packages

2005-12-19 Thread Teh Noranis Mohd Aris
Hi,
I'm learning to use packages from a book example to
create my own servlet instead of putting the code in
the examples webapp. However the following error
occurs:

HTTP Status 404 -
/ch03/servlet/com.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet

type Status report
message
/ch03/servlet/com.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet
description The requested resource
(/ch03/servlet/com.wrox.projsp.ch03.myfirstwebapp.MyFirstServlet)
is not available.

Apache Tomcat/4.1.31

How can I fix the error? I'm sure that the servlet is
in the correct directory and I've put the web.xml in
the WEB-INF directory. Did I miss anything? Please
help. Thanks.

Yours Sincerely,
TEH

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Please Help Me

2005-12-02 Thread Teh Noranis Mohd Aris
Dear All,
I've installed tomcat version 4.1.31 and tried to
start tomcat but the Tomcat window displays error
messages:
Catalina.stop: java.net.ConnectException: Connection
refused: connect java.net.ConnectException
.
.
.
How can I fix this problem? Please help me. Thank you.
 



__ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Please Help Me

2005-12-02 Thread Teh Noranis Mohd Aris
Dear All,
I've installed tomcat version 4.1.31 and tried to
start tomcat but the Tomcat window displays error
messages:
Catalina.stop: java.net.ConnectException: Connection
refused: connect java.net.ConnectException
.
.
.
How can I fix this problem? Please help me. Thank you.



__ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Problem Solved

2005-12-02 Thread Teh Noranis Mohd Aris
Dear All,
For those who replied, thank you so much. I've already
solved the problem. I think that I've downloaded the
wrong file. I've uninstalled tomcat and installed it
again and it works. Thank you again.

Regards,
Teh 



__ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]