alsoumhi 0 Junior Poster in Training

Hi experts, I have a problem which is I can't write arabic text as values of table , here is the steps I have done , please help me and correct me if I am mistaken

this is what I did:
**************************************************
set names utf8 COLLATE utf8_general_ci;

create database see;

use see;

ALTER DATABASE see CHARACTER SET utf8 COLLATE utf8_general_ci;

create table one (name varchar(20) ) default charset utf8;
ALTER TABLE one CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE one MODIFY name TEXT CHARACTER SET utf8 COLLATE utf8_general_ci;

insert into one(name)
values("عÙÙ");
**********************************************************************************

everything works fine , this is what appear to me when I press status:
**********************************************************************************
Connection id: 12
Current database: see
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.1.49-community MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 9 hours 40 min 53 sec

Threads: 1 Questions: 106 Slow queries: 0 Opens: 32 Flush tables: 1 Open ta
bles: 1 Queries per second avg: 0.3
**********************************************************************************

so when I do insert command and write the arabic text , it appears unaderstandable word and is saved like that , why!!! , is it because mysql prompt doesn't support arabic language , …

alsoumhi 0 Junior Poster in Training

Hi experts, I have a click button called log off , here once a user clicks it , task goes to logout servlet to end current user session . below is my code , I don't know why it works fine with mozilla firefox and google chrom but not working with internet explorer. please help me I did many tries till got headache

response.setHeader("Cache-Control","no-store"); //HTTP 1.1
            response.setHeader("Pragma","no-cache"); //HTTP 1.0
            response.setDateHeader ("Expires", 0); 

            HttpSession httpSession = request.getSession();  
            httpSession.setAttribute("validUser",null); 
            httpSession.invalidate(); 

            HttpSession session = request.getSession(false);    
            if(session == null)
                response.sendRedirect("/index.jsp");
            else
            response.sendRedirect("http://www.google.com");//just to test

here it goes fine to my index, but if I logged in again, I should enter a new session , but unfortunately this not happened in explorer , works fine with mozilla , and chroom.

I have also done in my index.jsp the check like below:

<%
     if(session!=null){
              session.setAttribute("validUser",null);
             session.invalidate();

%>

just to erase whatever previous session . But why session exist on same page !!!!!!!!!!!!!! only in explorer , it makes me open new explorer for new user and that is what I don't want !!!!!!

alsoumhi 0 Junior Poster in Training

Hi experts , I have finished my web application , and now I would deploy it in centos , I need to call my web application the index page like this url http://intranet it goes directly to index page . My web application including the index page is under Root directory . actually I can access my web application and the index page by using http://ipAddress and I don't want to use ip , I want the host name instead
please tell me how to change this , resolving ip address to host name called intranet

is there away to do that

alsoumhi 0 Junior Poster in Training

Hi guys , I am trying to convert a web page to pdf , I have searched about this a lot but I did find any answer

I have one program to convert using YAHP converter but I couldn't understand its parameters used in the program

String  fontPath = getParameter(args, "--fontpath");
String  password= getParameter(args, "--password");
String  keystorePath     = getParameter(args, "--ks");
String  keystorePassword = getParameter(args, "--kspassword");
String  keyPassword   = getParameter(args, "--keypassword");
String  cryptReason		 = getParameter(args, "--cryptreason");
String  cryptLocation    = getParameter(args, "--cryptlocation");

I don't know what are valid values can be assign to these parameters?!!!!

please guys if you have another way to convert please teach me it and show me the sample of the code if possible
thanks a lot

alsoumhi 0 Junior Poster in Training

I have done what you have said but still doesn't work although I save configuration after modification of web.xml

I would tell that my server is running on Centons , is it the problem ?
pleasse I need help with this

alsoumhi 0 Junior Poster in Training

Hi all , I am trying to map a user to a jsp page when he tries to enter to a directory of my application using URL. let say my web directory is called school and it has a directory called pages . now I need to map a user to error page when he tries to access to pages directory using URL
something like this:
http;//ip_address/school/pages
I have done this in web.xml but it is not working why!!!:

<servlet>
<servlet-name>myjsp</servlet-name>
<jsp-file>/school/errorPage.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>myjsp</servlet-name>
<url-pattern>/school/pages</url-pattern>
</servlet-mapping>

but it is not working ,
please tell me if I am wrong and how I correct it , please if you have another idea please tell me
I need it to apply it in my application
thanks

alsoumhi 0 Junior Poster in Training

Hi guys, I am trying to restrict users to access the sources of my application so I have used tomcat-users.xml file , but later I will be facing a problem which is how if I have a lot of authorized users , so I will add each one to that file manually , i think it is not efficient way . Furthermore , I am having an application that lets users used its resources based on the user account in database. if the user has an account in database he/she can login to the application and use the resources , so how can I use this idea with tomcat-users.xml just to avoid the increase number of authorized users in tomcat-users.xml
I hope you understand my question . I don't mind to repeat it again if you have any question
please help me guys because I want to prevent unathorized users to access directly using URL in my application
thank you very very very much

alsoumhi 0 Junior Poster in Training

Hi guys I am trying to prevent user to access directly using URL to my application , so in order to do that I have used security constraint in web.xml file and it works with me . my problem is in my application I am using href and redirect method in my servlets to redirect a user , here the server will not redirect a user to required pages but redirecting a user to error page "access deny" , it is like a user accessed directly from URL

please help me how to solve this problem.

I have seaeched about how to secure your pages from accessing directly using URL which is through putting all the pages under web-inf directory , I hope if you tell me how to do that , what changes i have to do in my web.xml

alsoumhi 0 Junior Poster in Training

Hi experts, I am having very small error with my attachment file.
the thing is , if I let my servlet send e-mail fwith attachment file exists on my computer and that file I edit by myself , there is no error with my file , so if i download it from my e-mail and open it again i will find it as I sent it. however , if that file is created by program and let my mail servlet to send an e-mail with that file as an ttachment file , then if i download it from my mail , i will not get it as it is edited by the program
let' say the program edits the file like this:
hello how are you guys
let's see if the file works or not
this is as a test only
thank you very much

I will get this after download:
hello how are you guys? this is as a test only ?thank you very much
actually this character( ? )is not what I saw , just to let you understand me , because I couldn't copy paste the real character, and if I do so it will give me here as new line
do you know what is the solution , please help me guys,
last thing if I would create (doc or pdf) file how can I do that instead of text file please help me
goood luck
thanks

alsoumhi 0 Junior Poster in Training

hi experts, hope you are fine.
I am having a connection problem from client side to my servera(localhost:8080/project). client can access to my normal pages either jsp or html. However, for the jsp pages that show information stored in database , they are not appeared in client side and I got message say "connection reset while the page was loading"
please could you help me , in how to let these pages read information from database quickly and thereby will be shown in client side

alsoumhi 0 Junior Poster in Training

hi all , I have finsihed my small project(online form system), I mean the development stage, now I am looking
for how I deploy it in windows, exactly windows professional environment . what do I need in order to successfully access to online form project installed in windows professional. I would like to inform you that I have installed the tomcat server to the machine which I will use to run my project . I did everything(installation tomcat , setting java home, class path)to my machine as I do in the development stage.
or do I have to only change the port number from 8080 to 80.

please guys tell me , what I did is correct,or wrong , or I miss something important
actually I prefer if you give me the instruction of the full deployment of a project.
thank you very much

alsoumhi 0 Junior Poster in Training

Hi all, I am trying to access login page (html page) from subdirectory of my web directory , the login page calls loginServlet which is reponsible for authintication, then the loginServlet response back to the client a web page to the user(whether user or adminstrator) .
my web directory called project.
my subdirectory for pages called pages.
my problem is I can access to login by this http://localhost:8080/project/pages/login.html
and once I get login page and submit the page I get this error
(The requested resource (/project/pages/login) is not available.)
why is that? please help me.
I wrote like this in web.xml :
<servlet>
<description>
this to the login page
</description>
<display-name>this is for login servlet</display-name>
<servlet-name>loginServlet</servlet-name>
<servlet-class>
projectPackage.login
</servlet-class>
</servlet>
and I wrote this to call loginServlet in login page:
<form action="/pages/login" method="post" name="loginForm" onsubmit="return ValidateContactForm();">
what is wrong I did please help me guys
thank you very much.

alsoumhi 0 Junior Poster in Training

hi all, I have simple question which is how to access to servlets inside subdirectories of classes directory?
I know that for one subdirectory inside the classes directory , you can access to servlets like this
http://host/servlet/packageName.ServletName
but how about the servlet is inside one or more subdirectories? I have tried this
http://host/servlet/packageName1/packageName2/packa geName3.ServletName
but it doesn't work , please can some one help me .
thank you

alsoumhi 0 Junior Poster in Training

I want to understant pager-taglib idea , how to use it , where to install it in which directory.
please provide me with tutorials that can explain it with clear examples because I read about it and got confused
thank you in advance

alsoumhi 0 Junior Poster in Training

Hi all, I am having a problem in JSP, it is very simple.
I have a java class and a JSP program, my JSP program will call the a method of java program in order to work as one complete application .however, I got an error says undetermined method.
Based on what I know , java classes(not the source code) under (WEB-INF/classes) and the JSP under the root
I did this , I still got errors.

or may be I import my java program wrongly, I did this(<%@ page import="classes.*" %>)
please help me

alsoumhi 0 Junior Poster in Training

there is no way to disable back button , is there a way other than that. I have searched about this but I reached to use class called session . I searched about its method to prevent user getting back but I didn't find that . please help me guys with just simple code example

alsoumhi 0 Junior Poster in Training

hi guys, I am doing online form project, I get problem with navigation.
the user can forword and back the page . I need to prevent user from that. I mean that once user gets new page , he can't get the prevouis page , but it asks him to login again.

can I do this in servlets please help

alsoumhi 0 Junior Poster in Training

hi guys, hope you are fine. I have project is about online form appliation , I have done half of the project, the part that the client login to the system and choose a form, filling the form , then sending to adminstrator a message saying one user has applied and attach the form that use has applied, lastly save form files in directories . my problem is with adminstrator side. I need to let adminstrator control the system such a way approve or disapprove to the form that the user applied for. I don't know how the webpage of adminstrator will look like after login page.

In my project, I did't create explicitly database for the forms and users. what I did is I keep sve the data user entered as a text file and keep the text file in directories.

let say two users we have david and nansi . both of them applied using my online system, so the files will be kept in following path:

E:/Directories/david/2010/08/leave form/form1.txt
E:/Directories/david/2010/08/leave form/form2.txt
E:/Directories/david/2010/08/registration form/form1.txt

E:/Directories/nansi /2010/08/application form/form1.txt
E:/Directories/nansi /2010/08/application form/form2.txt
E:/Directories/nansi /2010/08/ leave form/form1.txt
E:/Directories/nansi /2010/08/teaching form/form1.txt

the adminstrator should reply to these forms applied by users
by approved or not approved

I don't know how I let my webpage for adminstrator will look like .
I have to show last change adminstrator did to the webpage next time adminstrator login , not to get new …

alsoumhi 0 Junior Poster in Training

Thank you guys you do the best , I will read the articles first then come to you if I face something

Thank you again

alsoumhi 0 Junior Poster in Training

Hi experts, I have finished writing my servlets and web pages. all my servlets tested using tomcat in windows operating system. In other words , I have finished the development stage. Now I need to move all my servlets and web pages to web server for deployment. but my web server is Centos web server. I don't know where to put servlets and web pages (i don't know in which directory in the server)

also do I need to install java program (like JCreator )to run the servlets....

please guys tell me what to do , and where to start.

could you please help me , and thank you in advance

alsoumhi 0 Junior Poster in Training

Hi experts , I got problem and need help please.
I have created a servlet sends a message to the client, I have tried to attach a text file with message being sent but I couldn't do that. please help me how to attach a file with a message.

is there something like this :


File file = new File("E:\\text.txt");
Message message = new MimeMessage(session);
.
.
.
.
message.setSubject(subject);
message.setText(text);

message.attach(file);//something like this statement

thank you in advance

alsoumhi 0 Junior Poster in Training

thank you I got the point

alsoumhi 0 Junior Poster in Training

Hi experts, I got problem in servlet. I have a web page that has two buttons (submit button and update button) , both buttons call the servlet. my question is how I let my servlet program distinguish the two buttons when one of the two buttons is pressed. the servlet contain two different contents , each content will run once the user click one button.

to be more specified, is there something like handling events between servlet and a web page like what we see in java GUI

alsoumhi 0 Junior Poster in Training

Hi experts, I am having a problem with sending mail from servlet
I have written this code :

import javax.mail.Session;
   import javax.mail.Message;
   import javax.mail.Transport;
   import javax.mail.MessagingException;
   import javax.mail.internet.MimeMessage;
   import javax.mail.internet.InternetAddress;
   import java.util.Properties;

 
 public class EmailSenderDemo {
   public static void main(String[] args)  {
    
        String from = "ali@mlabs.com";
        String to = "ali@mlabs.com";
        String subject = "Hi There...";
        String text = "How are you?";
        String host = "smtp.mlabs.com";
    
        Properties properties = new Properties();
        properties.put("mail.smtp.host", host);
        properties.put("mail.smtp.port", "25");
        properties.put("mail.smtp.debug", "true");
        Session session = Session.getDefaultInstance(properties, null);
        try {
                   Message message = new MimeMessage(session);
                   message.setFrom(new InternetAddress(from));     message.setRecipient(Message.RecipientType.TO, new       InternetAddress(to));
                 message.setSubject(subject);
                message.setText(text);
          
               Transport.send(message);
        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }
}

but I got this error:

javax.mail.MessagingException: Unknown SMTP host: smtp.mlabs.com;
nested exception is:
java.net.UnknownHostException: smtp.mlabs.com
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at EmailSenderDemo.main(EmailSenderDemo.java:53)
Caused by: java.net.UnknownHostException: smtp.mlabs.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
... 7 more

please help!

alsoumhi 0 Junior Poster in Training

thank you very much
but what Id or name, this is my menu selection:

<select>
  <option value ="sydney">Sydney</option>
  <option value ="melbourne">Melbourne</option>
  <option value ="cromwell">Cromwell</option>
  <option value ="queenstown">Queenstown</option>
</select>

what is the name or id for that

alsoumhi 0 Junior Poster in Training

Hi experts, I have two questions, please help me because I am trying
to create an application and I stopped because of these

1) how to read data in servlet from a web page for select menue
I have used [request.getParameter("?????")] but I don't know which name I put inside getParameter

2)I have two servlets, one servlet read from web page and another servlet from another web page , my question is how to let the second servlet gets the information(data) that the first servlet has read

i have tried to create an object of first servlet in the second servlet in order to make call of methods of the first servlet that contain data but I got this error:

The server encountered an internal error () that prevented it from fulfilling this request.


Thank you very much in advance

alsoumhi 0 Junior Poster in Training

Hi Friends hope you are fine, my question is how to send a respond message created by a servlet to a specific e-mail. let's say I create a registration servlet, this servlet will send a respond message to an e-mail , instead of showing the respond message as a web page

I hope you understand me and thanks for cooperation and help in advance

alsoumhi 0 Junior Poster in Training

hi all , I have a simple question , let's say we have a servlet program and a web page . the question is how to make a servlet calls the web page and sends it as a respond to any request coming to the servlet.
Is there any statement something like the data file
File dataFile = new File("Input File.txt");

I know I can send the web page by coding the web page in the servlet but I don't want it in that way I need it to be fully coded in html and just let the servlet calls it and sends it back to the request
how to do that ?

please help

alsoumhi 0 Junior Poster in Training

thank you I really appreciate your help

alsoumhi 0 Junior Poster in Training

hi all , my question is how to create a hypertext link in servlet so if the user click it, it shows another web page
or a message .

alsoumhi 0 Junior Poster in Training

this is my code

import java.io.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
   public class InputServlet extends HttpServlet
   {
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException, FileNotFoundException
          {
                     File Admin = new File("admin.txt");
                   
                   
                   
                    FileReader reader = new FileReader(Admin);
                     BufferedReader in = new BufferedReader(reader);
                     
                     String name = request.getParameter("Name");
                     String p = request.getParameter("password");
                     int password = Integer.parseInt(p);
                     
                     String line;
                     String array[]; 
                     line = in.readLine();
                     while(line != null)
                     {
                     	array = line.split("\t");
                        int filePassword = Integer.parseInt(array[1]);
                        
                        if(array[0].equals(name)  &&  filePassword == password)
                        {
                        	 response.setContentType("text/html");
                             PrintWriter out = response.getWriter();
                             out.println("<html>");
                             out.println("<head>");
                             out.println("<title>Input Servlet</title>");
                             out.println("</head>");
                             out.println("<body>");
                             out.println("<h1>");
                             out.println("Hello " + name); 
                             out.println("</h1>");
                             out.println("</body>");
                             out.println("</html>");
                             in.close();
                             break;
                        }
                        else
                        {
                              response.setContentType("text/html");
                             PrintWriter out = response.getWriter();
                             out.println("<html>");
                             out.println("<head>");
                             out.println("<title>Input Servlet</title>");
                             out.println("</head>");
                             out.println("<body>");
                             out.println("<h1>");
                             out.println("Sorry wrong Login entered!"); 
                             out.println("</h1>");
                             out.println("</body>");
                             out.println("</html>");
                             in.close();
                             break;	
                        }
                     }
                     
                     
         }
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException
         {
                    doGet(request, response);
         }
}
alsoumhi 0 Junior Poster in Training

Hi all , I have a servlet program, this program will get a user name and password from a web page. I need to check the user name and passsword entered by user with a data file has all user names and passwords. the thing is I know how to search and check if the name and password in data file or not . my problem is my servlet shows a message to me says


"description The server encountered an internal error () that prevented it from fulfilling this request.

java.io.FileNotFoundException: admin.txt (The system cannot find the file specified)
java.io.FileInputStream.open(Native Method)
java.io.FileInputStream.<init>(FileInputStream.java:106)
java.io.FileReader.<init>(FileReader.java:55)
InputServlet.doGet(InputServlet.java:15)
InputServlet.doPost(InputServlet.java:69)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:420)
org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.
Apache Tomcat/5.5.27


although I have put the compiled program with the file under Classes directory, I get the same error

and I have tried to put the program + its class + the file , under Classes Directory , I get the same error (exception)


please help!

alsoumhi 0 Junior Poster in Training

oobs thanks man

alsoumhi 0 Junior Poster in Training

hi all , I am new to this forum I have a simple question why getParameter() doesn't work with me . My java server page is as follow:

import java.io.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
   public class InputServlet extends HttpServlet
   {
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException
          {
                     String name = request.getParameter("Name");
                     response.setContentType("text/html");
                     PrintWriter out = response.getWriter();
                     out.println("<html>");
                     out.println("<head>");
                     out.println("<title>Input Servlet</title>");
                     out.println("</head>");
                     out.println("<body>");
                     out.println("<h1>");
                     out.println("Hello " + name); 
                     out.println("</h1>");
                     out.println("</body>");
                     out.println("</html>");
         }
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException
         {
                    doGet(request, response);
         }
}

my html code is below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Input Servlet</title>
</head>
<body>
<form action="http://localhost:8080/servlet/InputServlet" 

method="post">
Enter your name:&nbsp;
<input type="text" name=”Name">
<br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

the server should return (Hello) fllowed the name user entered it
but I get this Hello null why is that please help

alsoumhi 0 Junior Poster in Training

this is the error when i start running the default server and admin server , I don't know why , please tell me how to solve it

an error occurred while trying to start admin. check console
log for more details

alsoumhi 0 Junior Poster in Training

Hi all, I got an error when I start admin server
this is the error
an error occurred while trying to start admin. check console
log for more details

please help how to avoid this error please

alsoumhi 0 Junior Poster in Training

Hi all , I have been given a task which is to create a (log in )web page , user has to log in to the page after that a page with many links of forms such as leave form, feedback form,complain form,...etc. once a user has clicked to one of forms , the form page will be appeared to him/her to fill in. when it is finished, the details of the filled form goes to an e-mail

my questions:
1 - may I use java applet to create the (log in) page and form pages
if so , please guide me to tutorials I will try to do it by myself please

2- I have two operating systems linux and windows which one is better , because I have been asked to work in linux(web server) and I am not that much familiar with it So can I work in windows, I create the servlet programs and applets then I transferred the programs to Linux easily, is it possible to do that .

3-what version of servlet I may use and which server (tomcat )
or (JSWDK) I use for testing before going to web server

alsoumhi 0 Junior Poster in Training

thank you guys for every thing
I appreciate your help

alsoumhi 0 Junior Poster in Training

Hi all , I have decided to use java applets and java servlets regarding creating a form.(because I don't know other langauages except java)

guys the scenario is like this , visitors will enter to website, surfing it and then they will enter to feedback form , they have to fill it and click submit .

The four points I don't understand are
1) may I create the form in java applet
2) if I create the form using java applet, so this java applet program must be reside on client or server
3) if it is reside on client how can I do that we have many clients(Millions of them)
4) if it is on server how can I install it to server and make it run when visitor enter the URL for feed back form

please help me and answer my questions because I really don't understand the communication between java applet and servlets

alsoumhi 0 Junior Poster in Training

Thank you guys for your participation to my question . ok I have decided to use java applets and java servlets regarding creating a form.
guys the scenario is like this , visitors will enter to website, surfing it and then they will enter to feedback form , they have to fill it and click submit .

The four points I don't understand are
1) may I create the form in java applet
2) if I create the form using java applet, so this java applet program must be reside on client or server
3) if it is reside on client how can I do that we have many clients(Millions of them)
4) if it is on server how can I install it to server and make it run when visitor enter the URL for feed back form

alsoumhi 0 Junior Poster in Training

Hi all , I have been assigned to do a task which is to create a web based application, the task is actually a normal form application, I have to use that form and make it online as a web-based application
and store the information in a database

I know I can do that using php or other language but I really don't know how to use these languages , I know only in java and C

please tell me if I can do it in java, guide me guys please
if there are tutorials please give me the links I will try to read and apply please guys help me

alsoumhi 0 Junior Poster in Training

Thank you Narue, I appreciate your participation to my question
but could you tell me the tutorials,examples,lessons showing what I have said please
I really want to learn something and I am sure I choose the right place

alsoumhi 0 Junior Poster in Training

Hi all , My question is that I want to know if possible I use C language dealing with windows such as I create a folder ,file, and show for example a pop up message says hi when windows starts to operate . I mean can I do these kind of stuff just using C programs

my second question is "can C language be used as a code of virus
if yes how or no why"

alsoumhi 0 Junior Poster in Training

first of all, what is the value of variable (s) here in the program, it is assumed here as it is zero , is it the value that you want it or not

secondly the looping will be infinite because value of variable (a) and value of variable (b) is always same , therefore check it again to make the loop finite

hope it helps
thanks

alsoumhi 0 Junior Poster in Training

Hi gys I hope you all fine
I just have a question that I would send two UDP packets from the client to the server and the server will reply back the both messages to the client , my problem is that my program only sends one packet to the server not the both and thereby the server reply by sending one packet although I send the two packets to server why ???

this is my CLIENT PROGRAM:

import java.io.*;
import java.net.*;
import java.util.Scanner;

public class NewClient {


    public NewClient() {
    }


     static final int BUFFERSIZE = 255;
    public static void main(String[] args) {
        try
        {
            Scanner scan =new Scanner(System.in);
            System.out.println("please input f1 massages");
            String message1 = scan.nextLine();
            System.out.println("please input f2 massages");
            String message2 = scan.nextLine();

            byte data1[] = message1.getBytes();
            byte data2[] = message2.getBytes();
            // create sendPacket
            DatagramSocket socket=new DatagramSocket(2222);



              DatagramPacket sendPacket1 = new DatagramPacket( data1,data1.length, InetAddress.getLocalHost(), 1111 );
              socket.send( sendPacket1 ); // send packet1
              System.out.println("your message1: "+message1+" has been sent to the server"  );
              DatagramPacket receivePacket1= new DatagramPacket(new byte[BUFFERSIZE], BUFFERSIZE);
              socket.receive( receivePacket1 ); // wait for packet
              String s1 = new String(receivePacket1.getData());
              System.out.println("we have received a message it is "+s1+"");
              System.out.println("I learn something "  );/*this step has not been reached why!!!!**/

              DatagramPacket sendPacket2 = new DatagramPacket( data2,data2.length, InetAddress.getLocalHost(), 1111 );
              socket.send( sendPacket2 ); // send packet1
              System.out.println("your message2: "+message2+" has been sent to the server"  );
               DatagramPacket receivePacket2 =new DatagramPacket(new byte[BUFFERSIZE], BUFFERSIZE);
              socket.receive( receivePacket2 ); // wait for packet
                System.out.println("we have received a message it is "+new …
alsoumhi 0 Junior Poster in Training

thank you gys for this information , but now I want to understand how it works
and in which cases and why we use it
I really want to understand this , and please if it is not problem you show me the books that
I can read from them about this or links or tutorials or examples

thank you I really appreciate your help

good luck

alsoumhi 0 Junior Poster in Training

thank you gys for this information but now
I want to understand what is the point behind this I mean in which cases we use this and how to use it
if not problem to you, please show me examples or recommend me books to read (that are possible to find), or some links I can go


thank you all gys I really appreciate your help
with best wishes
good luck

alsoumhi 0 Junior Poster in Training

Hi gys how are you, I really need your help to understand the idea for putting some parameters with main function, it is like this ( int main ( int a , int b , char* c) )
what is this and when we use it and how!!! ... I really need to understand this

alsoumhi 0 Junior Poster in Training

Hi guys hope you fine
I have a request and question, for my request I would like from you to recommend me
which books and tutorials that I may follow help me to understand how to read and write files in java I really need to know that. and for my question is how to make a float random ends with five or zero only. For example 0.25 , 0.30 , 0.35 , 0.40 , 0.45 ,0.50 , 0.55 , and so on till number one. I don't need a float numbet appears to me such as 0.23 , 0.14 , 0.78 , 0.99 , 0.61 , 0.12 , etc ... so how it's done that


thanks,
my regard

alsoumhi 0 Junior Poster in Training

please reply to me if it is correct or not