الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف احول بين URL و Path

مغلق
بدأه رامي العيساوي في 5 يونيو 2003 · 12 رد · 1,179 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

اخواني الاعزاء :

كما تعرفون ان الكلاس فايل :

File dir=new File("D:/tomcat4/webapps/ramyws/images");

نحدد له الباث في جهازنا اي local host و لكن اذا اردت تحديد عنوان URL له فلا يقبل اي:

File dir=new File("http://somesite.com/somefolder");

فما هو الحل برايكم ارجو مساعدتي بسرعة

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#2

انا اتكلم داخل صفحة JSP و لدي الصلاحيات المناسبة للقراءة من الموقع المحدد

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#3

No!! you shouldn't use the "File" class you should use HttpURLConnection or class URL, i am sorry i am in a hurry but let me give you a hint, i remember i used something like Encoding URLs or something, but using FILE will not work for you

sorry my pc is no arabic enabled

#5

اخواني الاعزاء سوف اشرح لكم القصة كاملة لقد كتبت برنامج JSP وظيفته انه ياخذ محتويات مجلد (في داخله صور فقط) ويعرض في الصفحة جميع هذه الصور مهما كان عدد الصور الموجودة داخل الملف و هذا الكود يعمل على ملف مجلد اححده انا في جهازي الكود سهل و مفهوم:

<% 



File dir=new File("D:/tomcat4/webapps/ramyws/images");



String[] images=dir.list(); // Returns a list of the files in the folder

int i=0;



while (i<images.length)

{

String name=(dir.getPath()+"/"+images);

%>

<p align="center">

[img=<%=name%>]</p>

<%

i++;

}

%>

وكما لاحظتم فان المجلد المطلوب هو داخل جهزي اي ان الكلاس File يقبل هذا الباث و لكن انا اريد ان ياخذ المجلد و المعلومات عن ماذا بداخله من الويب و ليس من جهازي اي كالتالي:

<% 

File dir=new File"http://somesite.com/somefolder");



String[] images=dir.list(); // Returns a list of the files in the folder

int i=0;



while (i<images.length)

{

String name=(dir.getPath()+"/"+images);

%>

<p align="center">

[img=<%=name%>]</p>

<%

i++;

}

%>

هل فهمت قصدي...... ارجو المساعدة

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#7

حسنا اخي سوف اجرب و لكنني اريد المجلد من غير و يب سايت

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#8

اخي لم نتجح الامور و الآ، اصبحت محتاجا للكتابة ايضا و ليس القراءة فقط فهل يوجد غير طريقة لكتابة الدليل

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#9

استخدم ../

او اكتب موقع ال JSP المستدعاه و موقع الصور حتى استطيع مساعدتك ان امكن

اللهم انا نسألك علما نافعا ونعوذ بك من حماقة الجهلاء
#10

هل حلت المشكلة

اللهم انا نسألك علما نافعا ونعوذ بك من حماقة الجهلاء
#11

للاسف لا المشكلة اكبر من هيك و معقدة رح اشرح القصة من اولها لذا رح اقطع الخط الآن و اكتبها و اعود و اضعها لتراها.

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#12

Java man

alssalam alakum,

How are you. Insha allah be kair?

There is a security issue as I understand here, and what you need to do is create a URL constructir using getDocumentBase plue your files to be able to access these pictures.

As I understand your problem is that you want to access pictures in a directory dynamically and display whatever in that directory of pictures dynamically.

If that is the case there are many solutions to your problem .

I have been busy lately at work and life in general but I will get back with you with a sample code to duplicate your solution.

Fi aman illah

Sorry for the English,I am at work and can't type arabic.

#13

الله يعطيك العافية اخي العزيز bawazeem بعد زمان افتقدنا لك و لله

انا بنتظارك اخي و شكرا لك جزيل الشكر

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

هذا الموضوع مغلق.

مواضيع مشابهة