SAP connector and Jsp page
hi Experts,
Can anyone please send me a working example project for SAP connector and Jsp page at [email protected]
Regards,
Sanjyoti.
Hi,
Use this example
import com.sapportals.connector.ConnectorException;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.execution.objects.INativeQuery;
import com.sapportals.connector.execution.objects.InvalidQueryStringException;
import com.sapportals.connector.execution.objects.QueryExecutionException;
import com.sapportals.connector.metadata.CapabilityNotSupportedException;
import com.sapportals.portal.ivs.cg.ConnectionProperties;
import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
import com.sapportals.portal.ivs.cg.IConnectorService;
import com.sapportals.portal.prt.component.*;
import com.sapportals.portal.prt.resource.ResourceException;
import com.sapportals.portal.prt.runtime.PortalRuntime;
public class TestJDBC extends AbstractPortalComponent
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
throws ResourceException
// Open a connection
IConnectorGatewayService cgService = (IConnectorGatewayService)
PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
ConnectionProperties prop = new ConnectionProperties(request.getLocale(),
request.getUser());
IConnection client = null;
try {
client = cgService.getConnection("System1", prop);
} catch (Exception e) {
response.write(e.toString());
return;
try {
// Issue SQL Query statement
INativeQuery query = client.newNativeQuery();
String queryStr = "SELECT [CategoryID], [CategoryName], [Description] FROM
[Categories]";
//IQuery query = client.newQuery();
//query.execute(queryStr);
Object result = query.execute(queryStr);
//ResultSet singleResult = ((ResultSet) result).getRow();
//IRecordSet result = query.retrieveRecordSet();
// Iterate returned result
ResultSetMetaData recordMetaData = ((ResultSet)result).getMetaData();
int colNum = recordMetaData.getColumnCount();
//result.beforeFirst();
while (((ResultSet)result).next()) {
for (int i = 1; i <= colNum; i++) {
response.write(((ResultSet)result).getString(i) + "<br>");
// Close the connection
client.close();
} catch (QueryExecutionException e) {
response.write(e.toString());
} catch (CapabilityNotSupportedException e) {
response.write(e.toString());
} catch (ConnectorException e) {
response.write(e.toString());
} catch (InvalidQueryStringException e) {
response.write(e.toString());
} catch (ResourceException e) {
response.write(e.toString());
} catch (SQLException e){
response.write(e.toString());
}catch(Exception e){
response.write(e.toString());
Similar Messages
-
hi everybody, I am trying to display some data from RFC on a JspDyn Page, I have prepared the project but the data from RFc is not displaying.... the code is
MyJspPage.java:-
package com.ust.jca;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.execution.functions.IInteraction;
import com.sapportals.connector.execution.functions.IInteractionSpec;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.ivs.cg.ConnectionProperties;
import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
import com.sapportals.portal.ivs.cg.IConnectorService;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.runtime.PortalRuntime;
import com.sapportals.connector.execution.objects.language.IFunction;
import com.sapportals.connector.execution.structures.IRecordSet;
import com.sapportals.connector.execution.structures.IRecordMetaData;
import com.sapportals.connector.execution.structures.IStructureFactory;
import com.sapportals.connector.metadata.functions.IFunctionsMetaData;
import java.util.Vector;
public class MyJspPage extends PageProcessorComponent {
public DynPage getPage() {
return new MyJspPageDynPage();
public static class MyJspPageDynPage extends JSPDynPage {
private RfcBean myBean;
public void doInitialization() {
public void doProcessAfterInput() throws PageException {
public void doProcessBeforeOutput() throws PageException {
myBean = new RfcBean();
((IPortalComponentRequest) getRequest())
.getServletRequest().setAttribute("myBean",myBean);
IPortalComponentRequest request =
(IPortalComponentRequest) this.getRequest();
// fill your bean with data here...
try {
//Alias is the name of the alias you defined in portal for SAP system
getSAPdata(getConnection(request, "P35"));
} catch (Exception e) {
e.printStackTrace();
this.setJspName("MyJspPage.jsp");
private IConnection getConnection (IPortalComponentRequest request,String alias)
throws Exception
IConnectorGatewayService cgService = (IConnectorGatewayService) PortalRuntime
.getRuntimeResources().getService(IConnectorService.KEY);
ConnectionProperties cp = new ConnectionProperties(
request.getLocale(),request.getUser());
return cgService.getConnection(alias, cp);
private void getSAPdata(IConnection client) throws Exception {
try
/* Start Interaction * */
IInteraction interaction = client.createInteractionEx();
// call the BAPI_MDDATASET_CREATE_OBJECT
IInteractionSpec interactionSpec = interaction.getInteractionSpec();
interactionSpec.setPropertyValue("Name", "ZHRESS_FIRSTDAY_SERVICE");
RecordFactory recordFactory = interaction.getRecordFactory();
MappedRecord input = recordFactory.createMappedRecord("input");
com.sapportals.connector.metadata.functions.IFunction function = client.getFunctionsMetaData().getFunction("T_ZHRESS_FIRSTDAY");
IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
//input.put("P35", request.getUser().getUniqueName());
input.put("SERVICEID","7");
input.put("YYUSER" , "EMP");
input.put("YYMOD","DIS");
MappedRecord importParams = recordFactory.createMappedRecord("input");
IStructureFactory structureFactory = interaction.retrieveStructureFactory();
IRecordSet table = (IRecordSet) structureFactory.getStructure(
function.getParameter("T_ZHRESS_FIRSTDAY").getStructure());
MappedRecord exportParams = (MappedRecord) interaction.execute(interactionSpec, input);
//myBean.setCW1((String) exportParams.get("CW1"));
//myBean.setCW1(((Integer) exportParams.get("T_ZHRESS_FIRSTDAY")).toString());
//myBean.setCW1((String) exportParams.get("T_ZHRESS_FIRSTDAY"));
IRecordSet exportTable = (IRecordSet) exportParams.get("T_ZHRESS_FIRSTDAY");
exportTable.beforeFirst(); // Moves the cursor before the first row.
while (exportTable.next()) {
String column_1 = exportTable.getString("PERNR");
String column_2 = exportTable.getString("ZDOJ");
myBean.setCW1((String)exportParams.get(column_1));
myBean.setCW2((String)exportParams.get(column_2));
//System.out.println(" COMPANYCODE_LIST-COMP_CODE = " + column_1);
//System.out.println(" COMPANYCODE_LIST-COMP_NAME = " + column_2);
myBean.createData(exportTable);
client.close();
catch(Exception e){}
@param ex
@param string
private void printException(Exception ex, String string) {
// TODO Auto-generated method stub
@param string
private void logMsg(String string) {
// TODO Auto-generated method stub
RfcBean.java:-
package com.ust.jca;
import java.io.Serializable;
import com.sapportals.connector.execution.structures.IRecordSet;
public class RfcBean implements Serializable {
private String CW1;
private String CW2;
@return
public String getCW1() {
return CW1;
@return
public String getCW2() {
return CW2;
@param string
public void setCW1(String string) {
CW1 = string;
@param string
public void setCW2(String string) {
CW2 = string;
@param exportTable
public void createData(IRecordSet exportTable) {
// TODO Auto-generated method stub
MyJspPage.jsp:-
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="request" class="com.ust.jca.RfcBean" />
Hello World
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
<hbj:textView
text="<%=myBean.getCW1()%>"
id="tv1"
design="HEADER2"
encode="false">
</hbj:textView>
<br>
<hbj:textView
text="<%=myBean.getCW2()%>"
id="tv1"
design="HEADER2"
encode="false">
</hbj:textView>
</hbj:form>
</hbj:page>
</hbj:content>Hi Sanjyoti:
JCo is one of the connectors for SAP backend through any Java/JSP/Servlet based applications. You need to have the SAP JCo libraries (Jar files) with you to connect to the SAP R/3 system, ofcourse along with the connection parameters.
Here is the sample scenario where you are connecting SAP RFCs/BAPIs with JSPs:
1: first you need to manage required JCo jar files and import it into your project lib folder. this is to have the JCo api at runtime to your application
2: import the library path into your JSP page
3: write a custom method to connect to SAP with connection parameter
4: you should have an idea of which Remote_Func_Module you are connecting and the input and output attributes
5: Execute the functional module and display the results and close the connection parameters.
Its almost like connecting to a RDBMS in a general scenario.
For more information about SAPJCo:
http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/content.htm
For example program1 to connect:
http://help.sap.com/saphelp_nw04/helpdata/en/6a/14e13d8ee4535ee10000000a114084/content.htm
For example program2 to connect:
http://help.sap.com/saphelp_nw04/helpdata/en/9d/14e13d8ee4535ee10000000a114084/content.htm
For example program a BAPI:
http://help.sap.com/saphelp_nw04/helpdata/en/de/e6c9255044b241a9401a3a1b7009a9/content.htm
For Tools & Services of SAPJCo:
https://websmp101.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000463649
If you still want already working program, I can mail it your email id.
Thanks,
MS -
PAR files and jsp pages into NWDS
Hi,
I need to modify transactions from the MSS 50.x package, i.e. HR transactions. I need to delete some fields on the screens.
The sysadmin was giving me a par file
com.sap.pct.hcm.attendanceoverviewperiod.par.bak
But when I import the par file into NWDS, the only thing I see is the portalapp.xml and a bunch of attribute files.
No jsp page, no class files..
When I browse into the directoria via sysadmin/support/portal runtime via WEB-INF, I do see all the necessary files. But how do I get the whole bunch of classes, jsp etc into NWDS? Download all single elements and put them manually into a NWDS project? There must be a better way
Any help will be gracefully awardedI tried it, but when I follow your instruction, NWDS gives me an error in the import wizard "<dir> does not have a .project file".
If I look in the .par file, there is no .project file at all.
I looked in the download of the PCD, there is no .project file either, but at least the java classes and the jsp.
Is it removed intentionally? Probably because it is an SAP business package? -
Hi.
I have a class called clsDbGrid under the ./classes/pkgDB and a JSP page under de ./web directory. I need to call the class from my JSP. I wrote the follow code:
<applet class="clsDbGrid.class" width="640" height="480">
The browse doesn't support JAVA
</applet>But this code doesn't work. What's wrong? I put the entire path for package and doesn't work again.
Please, I'm beginner in Java and need a help.
Thanks.
Marco.
P.S - Sorry for my terrible english. I'm from Brazil.See if this helps:
http://java.sun.com/docs/books/tutorial/deployment/applet/html.html -
I am to create a link verification program -- a simple java file with the database connection & some business logic and a JSP page that instantiates the my java file. It won't work. Everytime I run the jsp page, it gives me java.lang.NullPointerException. Can anyone give me some directions? The web server I am using is JRun.
Thank you
Below are my code:
JSP Page:
<%-- Verify Links
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="java.sql.*" %>
<%@ page import="java.net.*" %>
<%@ page import="pro.*" %>
<html>
<head>
<title>Results</title>
</head>
<body>
<%
try{
LinkConnection newconn = new LinkConnection();
newconn.initialize();
newconn.query();
newconn.close();
}catch (ClassNotFoundException cnfe)
out.println(cnfe);
catch (SQLException sqle)
out.println(sqle);
catch (NullPointerException npe)
out.println(npe);
%>
</body>
</html>
Java Code:
package pro;
import java.io.*;
import java.sql.*;
import java.net.*;
public class LinkConnection {
Connection con;
ResultSet RS;
Statement Stmt;
public void initialize() throws SQLException, ClassNotFoundException
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("XXXX", "XXXX", "XXXX");
public void query() throws SQLException
Statement Stmt=con.createStatement();
String strSQL="Select guideline_name, guideline_url from pgt_guidelines";
ResultSet RS=Stmt.executeQuery(strSQL);
while (RS.next())
String guidelinename = RS.getString("guideline_name");
String guidelineurl = ("http://" + RS.getString("guideline_url"));
try {
URL url = new URL(guidelineurl);
HttpURLConnection link=(HttpURLConnection)url.openConnection();
System.out.println("<font color='blue'>");
System.out.println(guidelinename);
System.out.println("<br>");
System.out.println(guidelineurl);
System.out.println("</font>");
System.out.println("<font color='red'>");
System.out.println(link.getResponseCode());
System.out.println("</font>");
System.out.println("<br />");
}catch (Exception e)
{System.out.println("<font color='yellow'>Error Link </font>")
public void close() throws SQLException {
RS.close();
Stmt.close();
con.close();i'm having the same problem, what is the solution to this
A Servlet Exception Has Occurred
java.lang.NullPointerException
at test.Lesson.runSql(Lesson.java:80)
===== Lesson.java file =====
package test;
import java.sql.* ;
import java.io.Serializable;
public class Lesson {
public Lesson( ) { }
//Line 9
public String runSql ( ) {
String browserOutput = "";
Connection sqlca = null;
Statement sqlStatement = null;
ResultSet myResultSet = null;
//Line 16
/* Connect to database, run SQL and produce output */
try {
/* Connection to the database */
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String theDatabase ="jdbc:mysql://localhost/employee";
sqlca = DriverManager.getConnection(theDatabase,"usr","pwd");
//Line 24
/* Construct and execute the sql, positioning before the
first row in the result set */
sqlStatement = sqlca.createStatement();
myResultSet = sqlStatement.executeQuery
//Line 29
("select emp_id, " +
"emp_lname, " +
"city, " +
"state," +
"zip_code, " +
"emp_fname " +
"from employee " +
"where emp_id < 250 " +
"order by emp_lname, emp_fname");
//Line 39
/* Construct the heading for the table */
browserOutput =
"<div align=left>"+
"<table border=0 align=left width=520>" +
"<caption><i><b>" +
"Employee Listing</b></i></caption>" ;
//Line 46
/* Construct the column headings for the table */
browserOutput +=
"<th align=left>Emp_id</th>" +
"<th>First Name</th>" +
"<th>Last Name</th>" +
"<th>City</th>" +
"<th>State</th>" +
"<th>Zip</th>" ;
//Line 55
/* Move to next row and & its contents to the html output */
while(myResultSet.next()) {
browserOutput += "<TR><TD>" +
myResultSet.getObject("emp_id").toString() + "</TD><TD>" +
myResultSet.getObject("emp_fname").toString()+"</TD><TD>" +
myResultSet.getObject("emp_lname").toString() + "</TD><TD>" +
myResultSet.getObject("city").toString() + "</TD><TD>" +
myResultSet.getObject("state").toString() + "</TD><TD>" +
myResultSet.getObject("zip_code").toString() + "</TD></TR>" ;
//Line 66
}//end of while
sqlStatement.close();
sqlca.close();
}//end of try
catch (SQLException e) {
//Line 72
browserOutput = " Error: SQLException: " + e.getMessage();
browserOutput= " Error: SQLState: " + e.getSQLState();
browserOutput= " VendorError: " + e.getErrorCode();
}//end of SQLException
catch (Exception e) {
browserOutput = " Error: JDBC Class creation: " + e.getMessage();
}//end of Exception
/**Line 80**/ finally {
try { sqlca.close(); }
catch(SQLException e) {
browserOutput = " Error: Closing connection: " + e.getMessage();
}//end of finally
/* Complete the html and return it to the Java Server Page */
browserOutput += "</table>" + "</div>" ;
return browserOutput;
} //end of runSql
}//end of Lesson -
Help With Integrating Servlet and JSP Page?
Hello There
--i made jsp page that contain name and description fields and add button
--and i made servlet that contain the code to insert name and description in the database
--and i want to make that when the user hit the add button
-->the entered name and description is sent to the servlet
and the servlet sent them to database?
here's what i 've done:
the jsp code:
<html:html locale="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
Categories Page
</title>
<html:base/>
</head>
<body style="background-color: white">
<form action="jpage.jsp" method="get">
<h1>
<center>
categories Operations
</center>
</h1>
<h3>
<label>Name</label>
<input type="text" name="name" value="" size="10" />
<label>Description</label>
<input type="text" name="description" value="" size="10" />
<input type="submit" value="Add" name="button" />
</h3>
</form>
</body>
</html:html>the servlet code:
import java.io.*;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.net.*;
class NewServlet1 extends HttpServlet{
Connection conn;
private ServletConfig config;
public void init(ServletConfig config)
throws ServletException{
this.config=config;
public void service (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
HttpSession session = req.getSession(true);
res.setContentType("text/html");
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/struts", "root", "");
PreparedStatement ps;
ps = conn.prepareStatement ("INSERT INTO categories (Name, Description) VALUES(?,?)");
ps.setString (1, "aa");
ps.setString (3, "bb");
ps.executeUpdate();
ps.close();
conn.close();
}catch(Exception e){ e.getMessage();}
public void destroy(){}
}The JSP Code:
<html:html locale="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
Categories Page
</title>
<html:base/>
</head>
<body style="background-color: white">
<form action="actionServlet.do?action=Additem" method="*post*">
<h1>
<center>
categories Operations
</center>
</h1>
<h3>
<label>Name</label>
<input type="text" name="name" value="" size="10" />
<label>Description</label>
<input type="text" name="description" value="" size="10" />
<input type="button" value="Submit">
</h3>
</form>
</body>
</html:html>The Servlet Code:
import java.io.*;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.net.*;
public class NewServlet1 extends HttpServlet implements SingleThreadModel {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException {
doPost(request,response);
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException {
String action = request.getParameter("action"); // action = "Additem"
if (action.equals("Additem")) {
String name = request.getParameter("name");
String description = request.getParameter("description");
RequestDispatcher reqDisp = null;
try{
Connection conn;
PreparedStatement ps;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/struts", "root", "");
ps = conn.prepareStatement ("INSERT INTO categories (Name, Description) VALUES(?,?)");
ps.setString (1, name);
ps.setString (3, description);
ps.executeUpdate();
ps.close();
conn.close();
reqDisp= request.getRequestDispatcher("./index.jsp");
reqDisp.forward(request, response);
catch (Exception ex){
System.out.println("Error: "+ ex);
}The web.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>NewServlet1</servlet-name>
<servlet-class>NewServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>NewServlet1</servlet-name>
<url-pattern>/NewServlet1</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>actionServlet</servlet-name>
<servlet-class>com.test.servlet.NewServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>actionServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app> -
Pass Object Between Applet and JSP Page
Hi all,
How can I pass an Object(such as Vector, File), rather than just string to the Applet from a JSP page?
Thank you.I used Base64Encoder and Base64Decoder from servlets.com utilities.
* convert any serializable object to a String
public synchronized static String objectToString(Serializable obj) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream(100);
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
byte[]bytes = bos.toByteArray();
bos = new ByteArrayOutputStream(); //to save the encoded String
Base64Encoder enc = new Base64Encoder(bos);
enc.write(bytes);
String encodedString = bos.toString();
//close all
enc.close();
oos.close();
bos.close();
return encodedString;
* Recreates the object from the encoded String
public synchronized static Object stringToObject(String str) throws Exception {
ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
Base64Decoder dec = new Base64Decoder(bis);
ObjectInputStream ois = new ObjectInputStream(dec);
Object obj = (Object)ois.readObject();
ois.close();
dec.close();
bis.close();
return obj;
} -
Applet to Applet communication between two seperate threads and jsp pages
Hi,
have two java applets running on two separate jsp pages. I am trying to have one applet talk to the other applet. I have tried putting the applets in a static hashtable, but I found out (through trial and error) that the memory is not shared between the applets. Needless to say the appletcontext object will not work as well. I have also tried to put the applet threads into a thread group, but it seems that the second applet can't find the first applet's threads. Is there a funky way that I need to create the threads for the threadgroup? Is there a way or type of object that I can use that will share the static memory between plugins? I am using 1.6 in IE. Or am I looking at this wrong and there is an easy way to do this and I am not seeing it.
Thanks,
MarcHi Mylene,
I hope I have understood your problem correctly. I can try to give you a tip. The times I've had to do a pop-up, for instance to show details or a part of the data in a table, I call a javascript function with the required parameters (an ID for details or an array of rows) when the button is pressed or a link is clicked. The function then builds a URL with all the paremeters and uses it to call the standard window.open function. After that the request is handled "as usual", ie as if you didn't actually do a pop-up but simply displayed a new page. The content of the pop-up is a jsp with all the required code to build the table and/or display the data. The contents of the table or data are retrieved with the help of the parameters sent.
I'm not sure if the portal kit provides some kind of standard functionality for this, but in the cases I've worked with J2EE solutions this has been the most common way of solving the problem.
I hope this helps.
kind regards,
Dionisios -
Message bundles accessed from JSF and JSP pages
Hello, everybody!
I'm developing a localized JSF application. It is working pretty well until now.
These are my message files:
mensagens.properties
mensagens_en_US.propertiesThis is how they're configured in faces-config.xml:
<application>
<resource-bundle>
<base-name>br.urca.www.biblioteca.web.mensagens</base-name>
<var>msg</var>
</resource-bundle>
</application>And this is how I access the messages in a page:
<h:outputText value="#{msg.titulo}" />Nothing new until now. But now there was a need for me to have a raw jsp page in
my web application. This page is displaying ok but I also need to access the
message bundles as I'm able to access in the normal jsp with the JSF components.
As you should know I can't use something like the above code with an +<h:outputText>+
to access the messages because this is a JSF component and I'll not be able to use
JSF components with this raw jsp page.
So, my question is: how do I access my localized messages from a raw jsp page? I
suppose there should be a way to do this, but unfortunately I started programming
to the web world in Java with JSF, not JSP, so I don't know how to do this with
JSP.
Thank you very much.
MarcosBalusC wrote:
Just include [jstl-1.2.jar|https://maven-repository.dev.java.net/repository/jstl/jars/] in your classpath and define the fmt taglib in your JSP. Nothing more is needed.
Hello, BalusC. Thank you for your help. We're almost there. After I have included the jstl-1.2.jar you provided me I can use the fmt tag and access message bundles from my raw jsp page (even though I had to provide other message bundles instead of the ones that I use in the other jsf pages, but it's better than nothing).
Now there just on problem to be fixed. The jsp page is not aware when I change the locale of my application. I change this locale in a jsf page.
I have this component:
<h:selectOneMenu value="#{pesquisaAcervo.idiomaAplicacao}"
valueChangeListener="# {pesquisaAcervo.idiomaAplicacaoMudado}" onchange="submit();">
<f:selectItems value="#{pesquisaAcervo.idiomasAplicacao}" />
</h:selectOneMenu>that calls this event in my backing bean class:
public void idiomaAplicacaoMudado(ValueChangeEvent e)
fIdiomaAplicacao.liberarItens();
Idioma idioma = Idioma.deString(e.getNewValue().toString());
// This line is for JSF
FacesContext.getCurrentInstance().getViewRoot().setLocale(idioma.localidade());
// This line is for Tiles
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().
put(org.apache.tiles.locale.impl.DefaultLocaleResolver.LOCALE_KEY, idioma.localidade());
}So, do I have to include another line in the idiomaAplicacaoMudado event above in order for the jsp page load the correct resource bundle? Or what else do I have to do?
Thank you.
Marcos -
Request dispatcher and jsp pages called from servlets
Given the following webapp directory structure:
root/
jsp/
..all jsp files
web-inf/
classes/
/servlets
..all servlet files
/com
..all other java class files
I have the jsp directory coded as: jspdir = "/jsp/" (and have tried variations
on this theme)
I try to open a new jsp page with the following code in a servlet in the above
servlet directory:
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher(jspdir + myjsp.jsp);
rd.forward(req, res);
rd continues to return null.
The jsp pages are not registered in the web.xml file for this webapp, if that
makes any difference.
Does anyone have any suggestions?
[problem.txt]
I create a small sample and put these files into /jsp in my war context
it works fine, please send me the example code you are using and the
environment description of the deployed application
I attached my samples, that work
Filip
~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
[email protected]
www.filip.net
"Bill Blackmon" <[email protected]> wrote in message
news:[email protected]...
>
> Yes, I am able to access the jsp pages with the url listed.
>
> "Filip Hanik" <[email protected]> wrote:
> >The weblogic servlet engine, is by default mapping anything that ends
with
> >*.jsp to be a JSP.
> >so there shouldn't be a problem. You didn't answer my first question,
> >are you able to access your JSP through the browser?
> >http://localhost:7001/root/jsp/myjsp.jsp
> >
> >Filip
> >
> >--
> >~
> >Namaste - I bow to the divine in you
> >~
> >Filip Hanik
> >Software Architect
> >[email protected]
> >www.filip.net
> >"Bill Blackmon" <[email protected]> wrote in message
> >news:[email protected]...
> >>
> >> The code you are reading in the message here was pasted in and
> >> looks bad, so maybe that's what you are referring to? The dispatcher
code
> >is called
> >> in the service() method of the servlet.
> >> I have a suspicion that the jsp directory needs to be defined someplace
> >-
> >weblogic.properties
> >> or web.xml?, though I don't see this in any of the examples that come
> >with
> >the product.
> >>
> >>
> >>
> >> "Simon Ng" <[email protected]> wrote:
> >> >
> >> >Hello Bill,
> >> > Did you put a <BR>
> >> >return;
> >> ><BR>
> >> >statement right after the dispatcher.forward() statement? Well, I am
> >assuming
> >> >your
> >> >code is in the doPost() or doGet() methods.
> >> >
> >> >Simon
> >> >
> >> >
> >> >"Filip Hanik" <[email protected]> wrote:
> >> >>if you do http://localhost:7001/root/jsp/myjsp.jsp
> >> >>
> >> >>do you get a result?
> >> >>
> >> >>make sure you have the right character case on the filename.
> >> >>
> >> >>Filip
> >> >>
> >> >>--
> >> >>~
> >> >>Namaste - I bow to the divine in you
> >> >>~
> >> >>Filip Hanik
> >> >>Software Architect
> >> >>[email protected]
> >> >>www.filip.net
> >> >>"Bill Blackmon" <[email protected]> wrote in message
> >> >>news:[email protected]...
> >> >>>
> >> >>> Given the following webapp directory structure:
> >> >>> root/
> >> >>> jsp/
> >> >>> ..all jsp files
> >> >>> web-inf/
> >> >>> classes/
> >> >>> /servlets
> >> >>> ..all servlet files
> >> >>> /com
> >> >>> ..all other java class files
> >> >>>
> >> >>>
> >> >>> I have the jsp directory coded as: jspdir = "/jsp/" (and have tried
> >> >>variations
> >> >>> on this theme)
> >> >>> I try to open a new jsp page with the following code in a servlet
> >in
> >> >the
> >> >>above
> >> >>> servlet directory:
> >> >>> RequestDispatcher rd;
> >> >>> rd = getServletContext().getRequestDispatcher(jspdir + myjsp.jsp);
> >> >>> rd.forward(req, res);
> >> >>>
> >> >>> rd continues to return null.
> >> >>>
> >> >>> The jsp pages are not registered in the web.xml file for this
webapp,
> >> >>if
> >> >>that
> >> >>> makes any difference.
> >> >>>
> >> >>> Does anyone have any suggestions?
> >> >>>
> >> >>
> >> >>
> >> >
> >>
> >
> >
>
[filipInclude.jsp]
[filipForward.jsp]
[filip.jsp]
-
Can SAP connector 2.0.1 be install in a pc which has only VS2005? I tried to install it and I received the following error:
YOU MUST FIRST INSTALLVISUAL STUDIO NET 7.1 INTEGRATED DEVELOPMENT ENVIRONMENT (IDE).
Can someone tell me if I can connect to SAP from VS2005 and how?
Thanks in advanceHi,
SAP Connector for MS .NET is not currently supported on Visual Studio 2005.
Please check the article Using SAP Connector for MS .NET (NCO) in Microsoft Visual Studio 200 to learn a workaround that enables easy design-time connectivity to SAP back-end systems in Visual Studio 2005 by creating the connector proxies in Visual Studio 2003 and porting them to Visual Studio 2005.
The link to this article is available in the Development Center under Additional Resources.
Regards,
Anne Tarnoruder
SAP NetWeaver Product Management -
Can I combine ASP and JSP pages?
Hi all,
Maybe a dumb question...
but Can I have ASP pages in my JSP application?
My problem is as follows:
In the JSP pages of my application, I have some links to ASP application:
http://domain/app.asp
Now IIS is running on another port. But I do not want to go through all my JSP and change the above link to:
http://domain:port/app.asp
Instead any request to http://domain/app.asp should be automatically forwarded to http://domain:port/app.asp
How can this be done? I am using Tomcat as my JSP container.
m_asuActually that is not what I am looking for. I dont want to 'buy' any product. I dont want to deploy ASP application with the JSP application. I just want to redirect the client to another website through an ASP page.
Only catch is that this ASP page needs to sit in my JSP container (Apache Tomcat). Is this possible?
m_asu -
Difference Between SAP Connectors and SAP Web Services Framework
Hello,
I would like to know the main difference between the SAP Connectors protocol (that uses SOAP) and the SAP Web Services Framework starting with NetWeaver.
Thank you,
Pedro CarrilhoHi Pedro,
I guess you are talking about Business Connectors and XI.
If that is the case, the differences are:
SAP XI belongs to SAP Netweaver Technology, whereas BC is an Integration tool provided by Webmethods.
SAP XI is based on a model called "Hub & Spoke" and Business Connectors are "point to point". So by using XI, what happens is that you do not redesign Solutions once again.
With XI you save the entire integration knowledge of a collaborative process centrally in SAP XI: Objects at design time in the Integration Repository and objects at configuration time in the Integration Directory. In this way, SAP Exchange Infrastructure follows the principle of shared collaboration knowledge: You no longer need to search for information about a collaborative process in each of the systems involved, but can call this information centrally instead. This procedure considerably reduces the costs for the development and maintenance of the shared applications.
Also SAP XI comes with pre-configured solutions bundled along with it, so you can straight-away use the solution instead of redesigning.
Also i believe SAP XI is integrated as a required solution for some new mySAP solution like SRM, there are some scenarios within SRM requires SAP XI to be used and we cannot use BC's there.
But incase if you do not have multiple systems connected and communication is between just 2 systems, BC should be sufficient, instead of investing on XI.
But i guess slowly SAP will be stopping its support for BC, as SAP XI can do everything that BC does and even much more.
Also go through these threads...
Re: Business connector
XI vs Connectors (Like JCo and .NET)
I hope this is what you were looking for...
Regards,
Abhy -
Connecting databeses with WML and JSP pages..!
I need information about how to connect databases with wap technologies using wml and jsp , I am waiting your resources, codes and helps.. And I would like to remind you , I am beginner about this topic , Only things that I know are Jsp and WML , I have no experience about wap and how to combine wml and jsp , So please be helper while you send your messages , If all your messages contains much detailed and supported complete sources and files , it will more helpfull for me ..
Thanks in Advance.
P.S : 1- ) if you want to contact direclty , mail address : [email protected]
2-) Don't post me complex references' URL , I have already made search on google,yahoo and etcAdditionally , I would like to learn what I have to need for this project .. Now , I already have winwap wap emulator and Websphere Studio.. Do I need special wap server or something else to test my applications..
Please , hurry up .. I really need your helps..
Ergin -
Connectivity between "SAP Connector and Java Iview".
hi Experts,
I have written a Java iview, and trying to connect r/3 by the java Iview, i am not able to track where i am goin wrong ?? Please help.
Is there anyway to check whether the connectivity is been established or not.I am really confused.
Code is :-
package com.rr.ess.DynPage;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.execution.functions.IInteraction;
import com.sapportals.connector.execution.functions.IInteractionSpec;
import com.sapportals.connector.metadata.functions.IFunction;
import com.sapportals.connector.metadata.functions.IFunctionsMetaData;
import com.sapportals.htmlb.Button;
import com.sapportals.htmlb.Form;
import com.sapportals.htmlb.GridLayout;
import com.sapportals.htmlb.Image;
import com.sapportals.htmlb.InputField;
import com.sapportals.htmlb.TextView;
import com.sapportals.htmlb.Tray;
import com.sapportals.htmlb.enum.InputFieldDesign;
import com.sapportals.htmlb.enum.TrayDesign;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.ivs.cg.ConnectionProperties;
import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
import com.sapportals.portal.ivs.cg.IConnectorService;
import com.sapportals.portal.prt.component.IPortalComponentProfile;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.resource.IResource;
import com.sapportals.portal.prt.runtime.PortalRuntime;
import com.sun.corba.se.spi.legacy.connection.Connection;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;
public class TestDynPage extends PageProcessorComponent {
public DynPage getPage() {
return new TestDynPageDynPage();
public static class TestDynPageDynPage extends DynPage {
Tray mytray;
Image Logo;
InputField myinputfield;
Button mybutton;
Button defaultbutton;
TextView text;
GridLayout mygrid;
String message;
String Str = new String();
* Initialization code executed once per user.
public void doInitialization() {
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
this.message = profile.getProperty("mymessage");
if(this.message=="")
this.message = profile.getProperty("defaultmessage");
* Input handling code. In general called the first time with the second page request from the user.
public void doProcessAfterInput() throws PageException {
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
InputField myinput = (InputField)getComponentByName("input");
if(myinput != null)
message = myinput .getValueAsDataType().toString();
try{
getConnection(request,"P35");
catch(Exception e)
public IConnection getConnection(IPortalComponentRequest request,String alias)
throws Exception {
IConnectorGatewayService cgService =
(IConnectorGatewayService) PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
ConnectionProperties prop = new ConnectionProperties(request.getLocale(),request.getUser());
IConnection connection = cgService.getConnection("P35",request);
getSAPdata(connection);
return cgService.getConnection("P35", prop);
public void getSAPdata(IConnection client) throws Exception {
/* Start Interaction * */
try{
IInteraction ix = client.createInteractionEx();
IInteractionSpec ixspec = ix.getInteractionSpec();
ixspec.setPropertyValue("Name", "HRMSS_RFC_EP_READ_PHOTO_URI");
// Create IFunction instance
IFunctionsMetaData functionsMetaData = client.getFunctionsMetaData();
IFunction function = functionsMetaData.getFunction("HRMSS_RFC_EP_READ_PHOTO_URI");
// CCI api only has one datatype: Record
RecordFactory recordFactory = ix.getRecordFactory();
MappedRecord importParams = recordFactory.createMappedRecord("CONTAINER_OF_IMPORT_PARAMS");
// Set scalar values
importParams.put("PERNR", "1012");
// Get scalar values
System.out.println("Invoking... " + function.getName());
MappedRecord exportParams = (MappedRecord) ix.execute(ixspec, importParams);
String scalar = (String)exportParams.get("URI");
Str = scalar;
finally {
if (client != null) {
try {
client.close();
//("* Iview: Closing connection ok.");
client = null;
} catch (Exception e) {
// logMsg("* Iview: Error closing connection.");
* Create output. Called once per request.
public void onPersonalise(Event event) throws PageException
IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
profile.setProperty("mymessage",this.message);
profile.store();
public void onDefault(Event event) throws PageException
IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
IPortalComponentProfile profile = request.getComponentContext().getProfile();
this.message = profile.getProperty("defaultmessage");
profile.setProperty("mymessage","");
profile.store();
public void doProcessBeforeOutput() throws PageException {
// create your GUI here....
IPortalComponentRequest req= (IPortalComponentRequest)getRequest();
//IResource rs = req.getResource(IResource.IMAGE,"images/CAR1.jpg");
IResource rs = req.getResource(IResource.IMAGE,Str);
Logo = new Image(rs.getResourceInformation().getURL(req),"Logo");
Form myForm = this.getForm(); // get the form from DynPage
myinputfield = new InputField("Input");
myinputfield.setDesign(InputFieldDesign.STANDARD);
mybutton = new Button("mybutton");
mybutton.setText("Personlise");
mybutton.setOnClick("Personalise");
defaultbutton = new Button("Default");
defaultbutton.setText("Default");
defaultbutton.setOnClick("Default");
text = new TextView("fgfdg"+Str);
mytray = new Tray();
mytray.setDesign(TrayDesign.BORDER);
//mytray.addComponent(Logo);
form.addComponent(Logo);
mygrid = new GridLayout(3,2);
mygrid.setCellPadding(2);
mygrid.addComponent(1,1,myinputfield);
mygrid.addComponent(2,1,mybutton);
mygrid.addComponent(3,1,defaultbutton);
mygrid.addComponent(3,2,text);
mytray.addComponent(mygrid);
myForm.addComponent(mytray);
Points would be awarded to helpful answers.
Regards,
Sanjyoti.hi Prashant,
Thanks for your reply.
I am able to see the Iview with all the components(textfield,buttons).
But the image is not displayed. and I am not able to check whether the connectivity is been established.
in this part of code
text = new TextView("fgfdg"+Str);
I am assigning the value of "Str", which i get from R/3 to "text",
but in the iview the value of "Str" is not displayed.
Regards,
Sanjyoti
Maybe you are looking for
-
Do we have an option to keep back up of mapping templates?
Hi, Can we keep back up of mapping templates by anyway? can we export mappijng templates to our local machines in xml format? Thanks in advance, Regards, Ujwalkumar
-
Sleeping in 20 minutes against my will
Hello, My MacBook is sleeping after 20/21 minutes, even though I want to listen to an iTunes' radio station while I am doing some cleaning on my home. I go to System Preferences and put it to save energy after 1 hour and it does not obbey me. Maybe I
-
Which model will I get, if I buy an unlocked iphone5 from the online apple store?
Will I get a GSM a1428 or GSM a1429? And is there a way to get a GSM a1429?
-
Z77a-G43 with I7 2600K no Video
I have been pulling my hair out, I recently purchased a new Z77a-g43 mother board and an I7 2600K processor. Everything posts fine and I installed win7 64bit and installed the drivers, but when it reboots it starts loading windows and then just shuts
-
Print (ppi) question
Two parts: I get the ppi concept but need clarification with the following: I always heard that ppi should be set between 200-320ish for printing. When I print in LR2 it sets itself at about 240, but what is the result if I UNcheck the option to prin