לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #2  
ישן 12-04-2007, 15:00
  Dnile Dnile אינו מחובר  
 
חבר מתאריך: 12.04.07
הודעות: 2
קוד רלוונטי:
בתגובה להודעה מספר 1 שנכתבה על ידי Dnile שמתחילה ב "Servlet-Applet communication"

אני צרף קטעי קוד רלבנטים:

SERVLET:






protected boolean coN(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ObjectInputStream inputFromApplet = null;

PrintWriter out = null;
BufferedReader inTest = null;

try
{
// get an input stream from the applet
inputFromApplet = new ObjectInputStream(request.getInputStream());

// read the serialized student data from applet
st1 =(String) inputFromApplet.readObject();

inputFromApplet.close();

// continue the process for registering the student object

}
catch(Exception e)
{
e.printStackTrace();
}
if(st1!=null)
return true;
return false;

}





APPLET






private String location=new String("http://localhost:8084/DnileServlt/SubServlt")//Data member
public URLConnection getServletConnection()
throws MalformedURLException, IOException {

// Connection zum Servlet ?ffnen
URL urlServlet = new URL(getCodeBase(), "/servlet/SubSrvlt");
URLConnection con = urlServlet.openConnection();

// konfigurieren
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type","application/x-java-serialized-object");


return con;
}
public void init(){
String st="moses";

try{
URL testServlet = new URL( location );

URLConnection servletConnection = testServlet.openConnection();


// inform the connection that we will send output and accept input
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);

// Don't use a cached version of URL connection.
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);

// Specify the content type that we will send binary data
servletConnection.setRequestProperty
("Content-Type", "application/octet-stream");
// send the student object to the servlet using serialization

ObjectOutputStream outputToServlet = new ObjectOutputStream(servletConnection.getOutputStre am());
// serialize the object
outputToServlet.writeObject(st);

outputToServlet.flush();
outputToServlet.close();
}catch(MalformedURLException ml){
ml.printStackTrace();
}

תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 00:35

הדף נוצר ב 0.03 שניות עם 12 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2025 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר