I want to get a image file from web (html page) in CICS 4.2 and JAVA(jcics). The file send by input file element in html ,but in my application i can't get it and get name of file only. i use jcics in cics 4.2.
html page :
<form name="fileform" method="post" action="/CICS/CWBA/tlc" enctype="multipart/form-data" >
<label for="ex6">Get picture</label>
<input type="file" id="exa" name="pic" accept="image/*" >
<input type="submit" id="save" value="save" />
</form>
in server side program :
customer.setPic( request.getFormFieldData("pic"));
Answer by MarkPocock (731) | May 21, 2015 at 03:41 AM
What you are trying to do should work exactly as you have described it.
I tried the same thing on my CICS TS 4.2 system and it worked as expected.
I used this simple piece of HTML:
<form method="POST" action="http://host:port/javaform" enctype="multipart/form-data">
<input type="file" id="exa" name="infile" accept="image/*" >
<input type="submit" name="Test" value="Test">
</form>
In CICS this drove the following java program which reads the formfield value and returns the input image file back to the browser;
public static void main(String[] args) {
Task t = Task.getTask();
if ( t == null )
System.err.println("CICSWeb: Can't get Task");
else
{
try
{
System.out.println("CICSWeb: Started");
HttpRequest request = HttpRequest.getHttpRequestInstance();
byte[] infile = request.getFormFieldData("infile");
System.out.println("CICSWeb: input file field length is " + infile.length);
System.out.println("CICSWeb: generating response");
HttpResponse response = new HttpResponse();
response.setMediaType("image/jpg");
response.setNoServerConvert();
response.sendFrom(infile);
System.out.println("CICSWeb: Completed");
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("CICSWeb: Unexpected exception " + e.getMessage());
}
}
}
If this is still failing for you then you could try an EXEC CICS WEB RECEIVE to get all the data CICS has received into your application. That would show if the right data has been sent in. You could also use CEDF to debug each JCICS command. A CICS trace would also show what is going on (you would need SO and WB trace components set to 1-2 and others at 1).
"I want to get a image file from web (html page) in CICS 4.2 and JAVA(jcics)..."
I seem to not understand what is being requested, exactly. Is this image file existing on the z/OS mainframe? What does morteza_pashaki mean by "from web"?
Also, what are the imports? Please include any library imports when you provide sample code.
Are the JCICS classes threadsafe? 1 Answer
Liberty JVM Server startup fails with abend 4094 reason code 00000014 2 Answers
DFHSJ0210 SETUP_CLASS_TIMEDOUT during CICS TS 5.2 Java Liberty Profile Initialization 1 Answer
DFHSJ1004 'No CICS-MainClass' exception when installing Java application 1 Answer
DFHSJ0002 0B07 in DFHSJJS and DFHDU0201 when starting multiple CICS JVM Servers 1 Answer