cancel
Showing results for 
Search instead for 
Did you mean: 

photo using jsp

Former Member
0 Kudos

iam using this standrad function module HRWPC_RFC_EP_READ_PHOTO_URI using JSP i want photo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

try this code;-



PrintWriter out = response.getWriter();
String from = request.getParameter("num1");


JCO.Client mconnection =
JCO.createClient("180",
"jshaik",
"1Q2W3E",
"EN",
"150.0.150.141",
"04");
out.write("created client");
try{
mconnection.connect();

JCO.Repository mrepository = new JCO.Repository("JCO Sample",
mconnection);

IFunctionTemplate functiontemplate =
mrepository.getFunctionTemplate("HRWPC_RFC_EP_READ_PHOTO_URI");

JCO.Function function = functiontemplate.getFunction();

function.getImportParameterList().setValue(from, "PERNR");

mconnection.execute(function);


String customer = function.getExportParameterList().getValue("URI").toString();

response.setContentType("text/html");
out.write("<html>" +
"<body> "+

//add image tag here with src value as *customer*
+"</body></html>");

}catch(Exception e){
out.write("exception");
out.write(e.getLocalizedMessage());
}finally{
mconnection.disconnect();
}

Regards,

Yogesh...

Edited by: Yogesh Varma on Aug 7, 2008 5:14 PM

Former Member
0 Kudos

Thanx yogesh and Thanx TO NIKHIL

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello All,

        We are facing problem while showing the URL of the image in the browser it is not showing anything!!

We have done exactly what you have said but still in vain.

The output we are getting when we try to access directly is

Output:

Signature Required: ContRep. A2, DocId 4A9C2CA4BAF368B7E10000000A330A2C, DocProt rcud, AccessMode r

And the URl is

http://<server>:<port>/sap/bc/contentserver/310?get&pVersion=0046&contRep=A2&docId=4A9C2CA4BAF368B7E10000000A330A2C&compId=data

Regards

Karthik

Former Member
0 Kudos

UIO

Former Member
0 Kudos

Hi ,

with JSp

import com.oreilly.servlet.MultipartRequest;

import java.io.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class UploadPhoto extends HttpServlet {

public void doPost(HttpServletRequest req, HttpServletResponse res)

throws ServletException , IOException {

res.setContentType("text/html");

PrintWriter out = res.getWriter();

String rtempfile = File.createTempFile("temp","1").getParent();

MultipartRequest multi = new MultipartRequest(req, rtempfile, 500 * 1024);

File rnewfile=null;

rnewfile = new File(new File("/").getAbsolutePath()File.separator"tomcat"File.separator"webapps"File.separator"ROOT"File.separator"Photo"File.separator"YourPhotoname.jpg");

out.println("<HTML>");

out.println("<head><title>UPLOAD PHOTO</title></head>");

out.println("<body>");

out.println("<Pre>");

Enumeration files = multi.getFileNames();

while (files.hasMoreElements()) {

File f = multi.getFile(name);

FileInputStream fin =new FileInputStream(f);

ImageInfo ii =new ImageInfo();

ii.setInput(fin);

fin.close();

fin =new FileInputStream(f);

FileOutPutStream fos =new FileOutPutStream(rnewfile);

byte sizefile[] = new byte[500000];

fin.read(sizefile);

fin.write(sizefile);

fos.close();

fin.close();

f.delete();

}

res.sendRedirect("Your.jsp");

}

}

i think with javascript also its possble search for previous threads .....

Regards ,

Venkat

srinivas_sistu
Active Contributor
0 Kudos

Hi,

If you use, HRWPC_RFC_EP_READ_PHOTO_URI function module, you can get the image URL, which you can use to display the image...

This will give you the url of the picture for example:

http://<server>:8000/sap/bc/contentserver/800?get&pVersion=0046&contRep=MA&docId=98EEFC79F979B343BC7...

So

inside your JSP

<%

String strImageURL="Above URL";

%>

<img source="<%=strImageURL%>">

Refer below thread for more info...

Regards,

Srinivas.

Former Member
0 Kudos

Below coding iam using to display image at that u have given some coding where i have to place that

PrintWriter out = response.getWriter();

String from = request.getParameter("num1");

//String to = request.getParameter("num2");

out.write("Hi servlet");

JCO.Client mconnection =

JCO.createClient("180",

"jshaik",

"1Q2W3E",

"EN",

"150.0.150.141",

"04");

out.write("created client");

try{

mconnection.connect();

// out.write("connnected");

JCO.Repository mrepository = new JCO.Repository("JCO Sample",

mconnection);

// out.write("connnected");

IFunctionTemplate functiontemplate =

mrepository.getFunctionTemplate("HRWPC_RFC_EP_READ_PHOTO_URI");

// out.write("got fn template");

JCO.Function function = functiontemplate.getFunction();

// out.write("got fn template");

function.getImportParameterList().setValue(from, "PERNR");

//function.getImportParameterList().getStructure("DESTINATION_TO").setValue(to,"CITY");

mconnection.execute(function);

// out.write("fn executed");

// JCO.Table mytable = function.getTableParameterList().getTable("FLIGHT_LIST");

// response.setContentType("text/html");

// out.write("<html>" +

// "<body>" "<table border='2'> "

// "<th> <td> AirLine <td> From City <td> To City<td>Date<td>Price </th>");

// for(int i=0; i<mytable.getNumRows(); i++, mytable.nextRow()){

// out.write("<tr>");

// out.write("<td>"(i1));

// out.write("<td>"+mytable.getString("AIRLINE"));

// out.write("<td>"+mytable.getString("CITYFROM"));

// out.write("<td>"+mytable.getString("CITYTO"));

// out.write("<td>"+mytable.getValue("FLIGHTDATE"));

// out.write("<td>"+mytable.getValue("PRICE")

// + " " + mytable.getValue("CURR"));

// }

//

//

// out.write("</body>" +

// "</html>");

String customer = function.getExportParameterList().getValue("URI").toString();

// String customer1 = function.getExportParameterList().getValue("LNAME").toString();

//JCO.Table mytable = function.getTableParameterList().getTable("PERSONALDATA");

response.setContentType("text/html");

out.write("<html>" +

"<body>" + "URI" + customer

"</body>""</html>");

// "<table border='2'> "+

// "<th> <td> AirLine <td> From City <td><td><td> </th>");

// for(int i=0; i<mytable.getNumRows(); i++, mytable.nextRow()){

// out.write("<tr>");

// out.write("<td>"(i1));

// out.write("<td>"+mytable.getString("PERNR"));

// out.write("<td>"+mytable.getString("EMPNAME"));

// //out.write("<td>"+mytable.getString("CITYTO"));

// //out.write("<td>"+mytable.getValue("FLIGHTDATE"));

// //out.write("<td>"+mytable.getValue("PRICE")

// //+ " " + mytable.getValue("CURR"));

// }

// out.write("</table></body>" +

// "</html>");

// out.write(returnstruct.getName());

}catch(Exception e){

out.write("exception");

out.write(e.getLocalizedMessage());

}finally{

mconnection.disconnect();

}