Skip to Content

BSP An Input field using a Java-Applet



A few weeks ago a customer came and asked for a website with an input field,
type file, with a preselected file. I said to him that this is impossible, because
of the security rules in the web. He answered that I have to solve the problem,
because he promised it to the department.

I searched the web, but I did not find any solution. After some investigation
it was clear that I will not solve the problem with pure-html. I found a Java-Applet
that seems to solve my problem. I tested it on the WAS, it works!

You find the Applet that I use in this weblog here: (
Please be fair, if You use the Applet productive, pay like described on the


To make the problem a little bit clearer, I will describe the scenario. If

You are only interested at the solution, You can skip this.

We have a non-SAP-Application, that writes a file on the local machine, a xml-file.

After that the user has the opportunity to call a link, which starts a browser

with the URL of a WAS-BSP-Application. We want to make it as easy as possible,

so we give the path and the name of the written file in the URL. So the User

has only to submit the page.


To show how the Applet works I created three bsp-pages:

    • default.htm – On this page we start the application, on this page you can

find the applet

    • load.htm – From default.htm we jump on load.htm. We use the Eventhandler

OnInitialization, where we read the file-data (multipart). After that we save

the data in a server side cookie

    • show.htm – Read the server side cookie, written in load.htm. Display the


First of all build a bsp-application, in this example I named it Z_JUPLOAD.

  Import the jar-file of the Applet (jupload.jar) that You uploaded from  (

  as a mime into the new application. Because this weblog is not about authentification

  set a default user in transaction SICF for this application.</p>


<p>The layout of default.htm. This page needs a page attribute, name: fileinput,
  auto: yes, type: string. With this URL-parameter you can preselect the file.</p>
<p>Sorry but for formatting purposes the following code segments will be contained
  only within Textareas:</p>
  <textarea rows="10" cols="79">
<%@page language="abap" %>
      <table width='550' class="clsTable">
          <td> </td>
             code   ="JUpload/startup.class"
             width  ="500"
             height ="300"
             name   ="JUpload"
             alt    ="JUpload by">
               <!-- Java Plug-In Options -->
               <param name="progressbar" value="true">
               <param name="boxmessage" value="Loading JUpload Applet ...">
               <%-- language dependend Buttons --%>
               <param name="labelAdd" value="Add">
               <param name="labelRemove" value="Remove">
               <param name="labelUpload" value="Upload">
               <param name="labelStopUpload" value="Stop Upload">

               <%-- Links --%>
               <param name="actionURL" value="load.htm">
               <param name="completeURL" value="show.htm">

               <%-- In this example only one file --%>
               <param name="maxNumberFiles" value="1">

               <%if not fileinput is initial.%>
               <param name="preselectedFiles" value="<%= fileinput%>">

               <param name="checkResponse" value="true">
               <param name="realTimeResponse" value="true">
               <param name="debug" value="false">

               Your browser does not support applets. Or you have disabled applet in your options.

               To use this applet, please install the newest version of Sun’s java. You can get it from  (










On this page we need the Eventhandler OnInitialization

  • event handler for data retrieval

data: i_num     type i.

data: i_entity  type ref to if_http_entity.

data: i_string type string,

      i_uname  type string.

data: itab_header_fields type tihttpnvp.

data: i_date type d,

      i_time type t.

  • Get the number of multiparts

call method runtime->server->request->num_multiparts


    num = i_num.

  • Search in all multiparts for the first file

do i_num times.

  call method runtime->server->request->get_multipart


      index  = sy-index


      entity = i_entity.

  call method i_entity->get_header_fields


      fields = itab_header_fields.

  read table itab_header_fields with key name = ‘~content_name’

                                         value = ‘uploadedFiles0’

                         transporting no fields.

  if sy-subrc = 0.

  •   This works only, if the file is a textfile

    call method i_entity->get_cdata


        data = i_string.




  • Save the data in a serverside cookie

i_uname = sy-uname.

i_date = sy-datum + 1.

i_time = sy-uzeit.

call method cl_bsp_server_side_cookie=>set_server_cookie


    name                  = ‘files’

    application_name      = runtime->application_name

    application_namespace = runtime->application_namespace

    username              = i_uname

    session_id            = runtime->session_id

    data_value            = i_string

    data_name             = ‘file1’

    expiry_time_abs       = i_time

    expiry_date_abs       = i_date

  •   EXPIRY_TIME_REL       =

  •   EXPIRY_DATE_REL       =





On this page we read the data from the server side cookie in the Eventhandler

OnInitialization. This page needs one page attribute, name: file1, auto: no,

type: string. We will read the server side cookie into this variable and display

it in the layout.

  • event handler for data retrieval

data: i_uname type string.

i_uname = sy-uname.

call method cl_bsp_server_side_cookie=>get_server_cookie


    name                  = ‘files’

    application_name      = runtime->application_name

    application_namespace = runtime->application_namespace

    username              = i_uname

    session_id            = runtime->session_id

    data_name             = ‘file1’


  •    EXPIRY_DATE           =

  •    EXPIRY_TIME           =


    data_value            = file1


<p>In the Layout we show the file-data. This makes only sense if you downloaded
  a textfile.</p>
  <textarea rows="10" cols="79">
<%@page language="abap"%>


  <body class="bspBody1">



If we both have not done any error, You should get this result:



You must be Logged on to comment or reply to a post.
    • Hi Craig,
      thank you very much for your hint. I checked it again. On a system with an english windows and an english browser there is no change. The problem is, the "Abbrechen" Button is a new feature in the latest version of jupload. If you use the version 0.80 there is no "Abbrechen" button. Probably the developer has forgotten to add a label-param or he has forgotten to refresh the documentation.
      The version 0.80 works fine as well.

      Best regards