Some question bout URLConnection anyone can help me

First Of all, i want to ask something bout URL connection
1. Is it possible to Modifying some files that i accessed via URLConnection without using CGI files ?
2. What is the limitation of URLConnection Class
As far as i know URLConnection Class only providing connection to resources, we can read it directly, but we cannot modify it directly.
Maybe someone Can help me with these class
package TKI.FileBuilder;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetData extends HttpServlet
private static final String CONTENT_TYPE = "text/xml; charset=windows-1252";
private static final String DOC_TYPE;
public static String getFilename(String Judul)
{ /*Fungsi untuk mengembalikan lokasi file tempat record akan disimpan */
String Filename= "";
String opener = Judul.substring(0,1);
opener = opener.toLowerCase();
if ((opener.equals("a")) || (opener.equals("b")) || (opener.equals("c")) || (opener.equals("d"))
|| (opener.equals("e")))
Filename = "http://127.0.0.1:8988/Final_Project-Project1-context-root/Admin/flatfiles/flatfileA-E.txt";
else if ((opener.equals("f")) || (opener.equals("g")) || (opener.equals("h")) || (opener.equals("i"))
|| (opener.equals("j")))
Filename = "http://127.0.0.1:8988/Final_Project-Project1-context-root/Admin/flatfiles/flatfileF-J";
else if ((opener.equals("k")) || (opener.equals("l")) || (opener.equals("m")) || (opener.equals("n"))
|| (opener.equals("o")))
Filename = "http://127.0.0.1:8988/Final_Project-Project1-context-root/Admin/flatfiles/flatfileK-O";
else if ((opener.equals("p")) || (opener.equals("q")) || (opener.equals("r")) || (opener.equals("s"))
|| (opener.equals("t")) )
Filename = "http://127.0.0.1:8988/Final_Project-Project1-context-root/Admin/flatfiles/flatfileP-T";
else if ((opener.equals("u")) ||(opener.equals("v")) || (opener.equals("w")) || (opener.equals("x")) || (opener.equals("y"))
|| (opener.equals("z")))
Filename = "http://127.0.0.1:8988/Final_Project-Project1-context-root/Admin/flatfiles/flatfileV-Z";
return Filename;
public void saveWritten(String title, String ID, String name, String Abstract, PrintWriter File)
try
// save data
System.out.println("****\n");
System.out.println(title+"\n");
System.out.println(name+"\n");
System.out.println(ID+"\n");
System.out.println(Abstract+"\n");
System.out.println("****");
File.println("****\n");
File.println(title+"\n");
File.println(name+"\n");
File.println(ID+"\n");
File.println(Abstract+"\n");
File.println("****");
}catch(Exception ae)
ae.printStackTrace();
public void getFile(String Judul,String nama, String Id, String Abstract, HttpServletResponse response)
{/* mengambil dan membuka file dari sisi server
berdasarkan huruf pertama dari judul Tugas akhir
File di Server di bedakan menjadi
- flatfileA-E
- flatfileF-J
- fletfileK-O
- flatfileP-S
- flatfileT-Z
// Memilah String dengan melihat huruf terdepan dari Judul untuk menentukan
// Flatfile mana yang akan dibuka
String Filename = "";
try
// open files
Filename = getFilename(Judul);
URL flatfile = new URL(Filename);
// open URL connection
URLConnection connection = flatfile.openConnection();
// set output True
connection.setDoOutput(true);
// set Write data properties to files via socket connection
PrintWriter Aen = new PrintWriter(connection.getOutputStream());
// save inserted data into flatfile
saveWritten(Judul,Id,nama,Abstract,Aen);
Aen.close();
//view Inserted File
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while(in.readLine()!= null)
System.out.println(in.readLine());
}catch( Exception ae)
ae.printStackTrace();
public void postData(String Judul, String Nama, String Id, String Abstraksi,HttpServletResponse response)
/*Ambil file sesuaikan dengan judul data masukan ke flatfile*/
getFile(Judul, Nama, Id, Abstraksi,response);
public void init(ServletConfig config) throws ServletException
super.init(config);
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
String J_Ta = "";
String N_Pem = "";
String ID_Pem = "";
String Abs = "";
try
{ // requesting object parameter and variables
J_Ta = request.getParameter("Judul");
N_Pem = request.getParameter("Nama");
ID_Pem = request.getParameter("IDPembuat");
Abs = request.getParameter("Abstraksi");
catch(Exception e)
e.printStackTrace();
// Masukkan semua data ke dalam flat file
postData(J_Ta,N_Pem,ID_Pem,Abs,response);
I'm trying to modify flatfiles using socket connection
But what comes out
No error comes out, but none inserted to the files

This is a simple edit and replace the existing file:
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
* Example of file modification via servlet
public class FileEditExample extends HttpServlet {
  File file_ = new File("borg.txt");
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
    throws IOException, ServletException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println("<html>");
      out.println("<head>");
      out.println("<title>Example file edit servlet</title>");
      out.println("</head>");
      out.println("<body bgcolor='linen'>");
      out.println("<h1>Edit me!</h1>");
      out.println("<form action='" + request.getRequestURI() + "' method='POST'>");
      out.println("<textarea rows='20' cols='80' name='text'>");
      synchronized (file_) {
        BufferedReader reader = null;
        try {
          reader = new BufferedReader(new FileReader(file_));
          String line;
          if ((line=reader.readLine())!=null) {
            while(true) {
              out.print(line);
              line = reader.readLine();
              if (line==null) break;
              out.println();
        } catch (IOException ioe) {
          ioe.printStackTrace(out);
        } finally {
          if (reader!=null) {
            reader.close();
      out.println("</textarea>");
      out.println("<br>");
      out.println("<input type='submit' value='resistance is futile'>");
      out.println("</form>");
      out.println();
      out.println("</body>");
      out.println("</html>");
  public void doPost(HttpServletRequest request,
                    HttpServletResponse response)
    throws IOException, ServletException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println("<html>");
      out.println("<head>");
      out.println("<title>Example file edit servlet</title>");
      out.println("</head>");
      out.println("<body bgcolor=\"white\">");
      out.println("<h1>Now you've done it!</h1>");
      out.println("<pre>");
      synchronized (file_) {
        BufferedReader reader = null;
        PrintWriter writer = null;
        try {
          reader = new BufferedReader(request.getReader());
          writer = new PrintWriter(new FileWriter(file_));
          String line;
          while ((line=reader.readLine())!=null) {
            if (line.startsWith("text=")) {
              line = line.substring(5);
              while (true) {
                line = deMimify(line);
                out.print(line);
                writer.print(line);
                line = reader.readLine();
                if (line==null) {
                  break;
                out.println();
                writer.println();
              break;
        } catch (IOException ioe) {
          ioe.printStackTrace(out);
        } finally {
          if (reader!=null) {
            writer.close();
          if (reader!=null) {
            writer.close();
      out.println("</pre>");
      out.println("<a href='" + request.getRequestURI() + "'>Back again</a>");
      out.println("</body>");
      out.println("</html>");
  // decodes mime encoding (probably there's been a utility to do this
  // added at some point, but I wrote this first in '96 and have never
  // bothered to check) 
  static String deMimify (String data) {
    int length = data.length();
    StringBuffer buffer = new StringBuffer(length);
    char ch;
    for (int i=0; i<length; i++) {
      switch (ch=data.charAt(i)) {
        case '+' :
          buffer.append(' ');
          break;
        case '%':
          ch = (char)( Character.digit(data.charAt(i+1), 16) * 16 +
                       Character.digit(data.charAt(i+2), 16) );
          i+=2;
        default:
          buffer.append(ch);
    return buffer.toString();
}Pete

Similar Messages

  • In my computer some of the iTunes files got deleted accidently and I couldn't reinstall it . Evrytime I try torun setup file  I am getting this error message "C:\Users\Rif\AppData\Local\Apple\Apple Software Update\" ,appreciate if anyone can help me on th

    In my computer some of the iTunes files got deleted accidently and I couldn't reinstall it . Evrytime I try torun setup file  I am getting this error message"C:\Users\Rif\AppData\Local\Apple\Apple Software Update\" ,appreciate if anyone can help me on this pls?

    Even after deleting all files and folders from hard drive i am still getting this error!!

  • Hi, using iphoto 6, i suddenly lost albums: they are still in the directory, but no pictures in some albums.Using finder, I can locate the pictures and even get preview. But impossible to import them. Anyone can help? thanks

    Hi, using iphoto 6, i suddenly lost albums: they are still in the directory, but no pictures in some albums.Using finder, I can locate the pictures and even get preview. But impossible to import them. Anyone can help? thanks

    Try these in order - from best option on down...
    1. Do you have an up-to-date back up? If so, try copy the library6.iphoto file from the back up to the iPhoto Library allowing it to overwrite the damaged file.
    2. Download <a href="http://www.fatcatsoftware.com/iplm/"><b><u>iPhoto Library Manager</b></u></a> and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.
    3. If neither of these work then you'll need to create and populate a new library.
    To create and populate a new *iPhoto 6* library:
    Note this will give you a working library with the same Rolls and pictures as before, however, you will lose your albums, keywords, modified versions, books, calendars etc.
    Move the iPhoto Library to the desktop
    Launch iPhoto. It will ask if you wish to create a new Library. Say Yes.
    Go into the iPhoto Library on your desktop and find the Originals folder. From the Originals folder drag the individual Roll Folders to the iPhoto Window and it will recreate them in the new library.
    When you're sure all is well you can delete the iPhoto Library on your desktop.
    In the future, in addition to your usual back up routine, you might like to make a copy of the library6.iPhoto file whenever you have made changes to the library as protection against database corruption.

  • HT1766 I had forgot my icloud id and the security questions given to it also now how can i get my icloud id plzz anyone can help me

    I had forgot my icloud id and the security questions given to it also now how can i get my icloud id plzz anyone can help me

    If you've forgotten your Apple ID, go to iforgot.apple.com
    Also:
    How to reset your Apple ID security questions.
    Go to appleid.apple.com, click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. (If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email)
    Go to the Password & Security section on the left side, and click on the link underneath the security questions that says 'Forgot your answers? Send reset security info email to [email]'.  This will generate an automated e-mail that will allow you to reset your security questions.
    If that doesn't work, or  there is no rescue email link available, then click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later.
    Next, go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.
    Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.

  • Pretty tech question here but if anyone can help I'd be so grateful..

    I've just updated from logic 7 to Logic 8.
    I'm currently working on a remix for a record label, I'm experiencing problems on playback in Logic 8 - basically it wont playback and cites this warning:
    **"Logic pro has detected a possible conflict between one or more third party MIDI audio drivers.**
    *Be sure to install the latest drivers for all audio and MIDI equipment connected to your computer, and remove any older or unused drivers."*
    I don't have a Roland MC505 in my studio, I'm running a MOTU 828mk2 and
    I have the most updated driver for my sound card installed.
    In Logic 7 I get the message below but playback isn't effected and I can access the entire project.
    *Instrument “Roland MC505” sends to a MIDI port named “EDIROL UM-2” of musical interface “EDIROL UM-2” which no longer exists.*
    *Please check if all MIDI interfaces are connected and switched on; otherwise adjust the instrument’s MIDI out port setting.*
    If anyone can help I'd me most grateful..

    My first thought, is for you to check your environment.
    If the song you're working on started out originally from someone else's Logic session, Their may be a Roland MC505 instrument in the MIDI layer of your environment.
    Hit Apple/8, and select MIDI from the tab in the upper right. Select and delete anything in there that doesn't apply to your set-up directly.
    See if that's what's going on...

  • I use "hdmi to component converter" to connect apple tv with my old plasma tv by component cable. Sound is ok but the picture split 2screens left and right. Still can't fix it. Anyone can help or has any idea? should I try convert to av?

    I use "hdmi to component converter" to connect apple tv with my old plasma tv by component cable. Sound is ok but the picture split 2screens left and right. Still can't fix it. Anyone can help or has any idea? should I try convert to av?

    Your TV hasn't entered some odd picture in picture mode has it with  two 'inputs' side by side?
    AC

  • Hello i forgot my i cloud password..anyone can help me to find my password.i already make a new apple id..but my icloud use another account..so how to reset my iCloud account plz hel me

    hello i forgot my i cloud password..anyone can help me to find my password.i already make a new apple id..but my icloud use another account..so how to reset my iCloud account plz hel me

    Making a new Apple ID is not a good idea, since you have to reset the password for that Apple ID anyway. All of your purchases are tied to the Apple ID that the iCloud account was created under. So, you have to retrieve the password for that Apple ID in order to sign into iCloud anyway.
    Go to Manage your Apple ID, and click on the Reset Password option (Apple - My Apple ID). Sign on with the Apple ID that the iCloud account was created under, and answer the security questions. If you do not remember the answers to the Security Questions, contact Apple Support to have them reset:
    ACCOUNT SECURITY CONTACT NUMBERS
    Cheers,
    GB

  • Hello THIS IS RAZA I GOT A MACBOOK PRO I HAVE A PROBLEM. PROBLEM IS how to solve this problem i have uploaded in .... all the time few days later on i face this problem in safari..... anyone can help me please.....thanks Screen Shot 2015-03-21 at 10.

    Hello
    THIS IS RAZA
    I GOT A MACBOOK PRO
    I HAVE A PROBLEM. PROBLEM IS how to solve this problem i have uploaded in .... all the time few days later on i face this problem in safari..... anyone can help me please.....thanks

    This is a scam. Do not phone these people, at best they will charge you for unnecessary 'cleaning' and at worst they will gain access to your Mac and steal your data. You've probably managed to install some 'adware' which is producing this fake warning. 'Adwaremedic' should remove it and is safe to use - please see
    http://www.adwaremedic.com/index.php

  • Iphone 4s doesn't charge and charging icon never change and i cannot open my phone now?anyone can help me?

    anyone can help me...my iphone 4s is not charging and the charging icon remain 1%...and there is a time it will come on and i will try to reset the settings but the problem it doesn't turn on once it dead.And i went to the apple store today and they said the charger connector or the charging port has been bent..they want me to pay 199 plus tax for another phone.Since i have this iphone 4s for 1 year and 2 months so it is very frustrating for me...So i decided not to buy another iphone..If i want to get another one not with apple anymore.So,when i got home,my wife try to make a research on the computer try to troubleshoot on our own because i cannot believe what the Apple manager told us "THE CHARGING COONECTOR HAS BEEN DAMAGED MAYBE BECAUSE i FORCED TO CHARGE EVEN IT DOESN'T FIT" it is a big insult for me because this is not my first phone..So my wife word hard for it and she keep on pressing the power button every 15 minutes..(10-15 seconds and it come on).And again i try to reset again its dead..I cannot turn back on....any advise?looks like apple wants only money and they are not trying there best to help there customer problem.

    My question is if the port is damaged,How come the charge sign come ff when i charge...but if there is a chance that the apple logo come on the icon of the battery never change still 1% but it will last for a day..doing phone calls and everything?Please help!

  • My itunes deletes all of my apps, music and movies every time i go on it and i have to recover it, its such a painand if anyone can help please dont hesitate to comment

    Every time i go on my itunes its as if i have just got it and i have never used it before it's as if it resets over night and the next day i have to load all my apps, music and movies back on to it. if anyone can help or if anyone knows someone who can please say something because its a right pain in the neck. My operating system is Windows Vista and my Itunes version is 10.2.2.12
    please help  

    Your problem is normally caused by a program locking the iTunes library so that iTunes can't close properly. There have been a number of causes fro this.
    There is a problem with media management software Vaio xml library Manager, the Vaio content manager and the Vaio Music Box software
    http://discussions.apple.com/message.jspa?messageID=8537277#8537277
    Work around:
    In Control Panel, turn off Vaio Content Folder Watcher and VAIO Content Metadata Intelligent Analyzing Manager.
    Also see:
    http://support.apple.com/kb/ts2715
    Sony has issued upgrades for some models, check you Sony download site to see if there is one available.
    I would check the work around first.
    If that's not it, try temporarily disabling you continuous backup to see if that is the cause.

  • Error message saying "Boot cam x64 is unsupported on this computer model" Anyone can help?

    Hi! After Windows is installed, (step 3 done) I get an error message when installing Windows assistance software (step 4). It says "Boot Camp x64 is unsupported on this computer model". Anyone can help?
    Version française:
    Je suis à faire l'installation et la configuration de Bootcamp mais rendue à l'étape d'installler le logiciel d'assistance de Windows (étape 4, disque préalablement gravé à l'étape 2), j'obtiens le message d'erreur suivant: "Bootcamp x64 is unsupported on this computer model" Quelqu'un peut-il me dire quoi faire? Merci pour ceux qui se donnent la peine de répondre! Caro

    copy the entire folder off the DVD to some where like Desktop (Windows) or flash memory drive
    Now find "BOOTCAMP64.msi" and control + click to see pop up menu and select "TROUBLESHOOT COMPATIBILITY"
    It has to do with Apple and Windows support for 64-bit OS using EFI and GPT (such as your Mac).
    Some MacBook models were and then were dropped from the list of "supported Macs"
    http://support.apple.com/kb/HT1846

  • Anyone can HELP

    Why I connect the oracle database by using java coding and I run it sometimes can but sometimes cannot and showed the following error :
    D:\KLTAY\JAVA>java CreateCoffees
    SQLException: [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed
    Please Help!!!!!!!

    (a guess)
    Is the ODBC connection already in use?
    (ps, you get better and faster results if you write a subject more descriptive than "Anyone can HELP", we know you need help, its the reason most people post here, some of us also post Evil Offtopic Threads
    Also some code can help, as does a stack trace, but don't just dump all your code on us, only the bits that are importent).

  • Hi apple users, I am in need of your expertise. I have a mov file and mp4 file which I need converted to DVD. However IDVD quality is terrible and wondering if anyone can help!?

    Hi apple users, I am in need of your expertise. I have a mov file and mp4 file which I need converted to DVD. However IDVD quality is terrible and wondering if anyone can help!?
    I created project in iMovie then exported it to MP4 and also MOV file at highest definition possible + I added it to iDVD and had a number issues about encoding errors regarding the mp4 file. MOV worked but the quality was terrible.....
    MOV file is as follows:
    4.08GB
    Codecs: H.264, ACC
    Colour Profile: HD (1-1-1)
    Dimensions: 1920 x 1080
    Duration: 12:33
    Audio Channels: 2
    MP4 File is as follows:
    3.02GB
    Codecs: H.264, ACC
    Colour Profile: HD (1-1-1)
    Dimensions: 1280 x 720
    Duration: 12:33
    Audio Channels: 6
    I have a MacBook Pro using the Yosemite system upgrade.
    I have updated iDVD and iMovie.
    I even bought the iSkysoft app from the mac store and that was terrible too.
    PLEASE HELP i am getting desperate and about to launch this macbook into the air
    2.66 GHz Intel Core i7
    Version 10.10. 2

    First of all, Hunt--thanks for responding!
    "First, where are you playing the MPEG-2, that you see that jitter?"
    On both a MacBook Pro, an Acer laptop and my Mac Tower. I would love to think that it is a problem with the playback system, and that if I merely send the file off to the duplicator they won't have the same problem. Maybe that is the case...I don't know if I have a choice rather than sending it off to see. But it happens in the same spots, in the same way, on all three of the players so I'm a little reluctant to have faith.
    "Another thing that can cause jitter in an MPEG-2 is the Bit-Rate - higher the Bit-Rate, the better the quality, but the larger the file. For a DVD, one is limited by the total Bit-Rate (both Audio & Video), but with longer prodcutions, some users choose too low a Bit-Rate. If this is the issue, one would need to go back to the original Project and do a new Export/Share."
    Of course, but in the case there is no more 'original project.' It is gone like the wind, stolen along with his computer and backups.
    I think I am stuck using one of two files as my master: a DVD he burned where I only see the stutter/vibration/jitter once, or the mpeg2 file where I see it three times. Hopefully, the duplication house can rip if off of one of them and not see the jitter. I know that in audio, my personal filed, you can do a lot to enhance already existing sound--EQ, compression, tape saturation emulation software, etc. I guess I'm hoping there is some kind of analog to the video world that address jitter after a source has been printed--if indeed the source has been printed to be jittery.
    Thanks,
    Doug

  • Urgent..please anyone can help me??????

    <b>Hi all..
    please anyone can help me.for this issue....
    My Requirements is first need to MR11 tarnsaction and create zmr11 transaction and also the copy the corresponding MR11 program create Z program, which i did it.
    but now i have create a POPUP window, which contain 
    Account:           Cost Centre:
                       Internal Order:
                      Profit Centre:
    We need to copy the program for MR11 and inside it, refer to a copy of MR_ACCOUNT_ASSIGNMENT, which would contain the logic for replacing the account number picked up from configuration with that entered by the user.
    The code that needs to be added here would generate a popup, accept the account number from the user, and replace the value of KONTO with this number, which is the export parameter for the Function Module.
    At some point before the call to this FM we would need to write code to generate a pop-up, which would be populated by the user with G/L account at run-time.
    i need to modiy this internal table::::
    Call function' CKMLGRIR_BUILD_GRIR_MAINTAIN'
       tables
          lt_grirpos = t_grirpos_package
    The internal table t_grirpos_package would need to be modified at this point and populated with the values populated by the user in the pop-up screen.</b>

    <logic:iterate id="dtoi" name="ages"
    collection="ages.keySet()" indexId="dtoi">
    <% interfaz.GenericDto dtoEA =
    (interfaz.GenericDto)dtoi; %>
    <% if (dtoEA != null){ %>
    <% }; %>
    </logic:iterate> Try the following (assuming "ages" is the HashMap - adjust as necessary):
    <logic:iterate id="dtoi" name="ages">
    <tr>
    <td><bean:write name="dtoi" property="value.edad"/></td>
    <td><bean:write name="dtoi" property="value.ctotal"/></td>
    </tr>
    </logic:iterate>

  • Hello, i´m trying to do a proyect that requires modulate and demodulate a text in QAM. i´ve been trying this for days but i can´t come uo with a solution, if anyone can help me, that would be great. thank you very much

    hello
    i´m trying to do a proyect that requires modulate and demodulate a text in QAM. i´ve been trying this for days but i can´t come up with a solution, I can not retrieve the text I am modulating and i do not understand why. I am new to using Labview  and would appreciate some help.
    if anyone can help that would be great.
    i have attached the vi that i´ve done.
    thank you very much
    Attachments:
    intentoproyectocom2.vi ‏78 KB

    I beleive they used the same concept that they did in iOS. One folder deep. If you think they should implement somehting more, then please use the feedback links in the forums FAQs to leave your comments and suggestions.
    Jason

Maybe you are looking for