Taglib and jsp pages question
Hi, I just recently got tag libraries to work and I am wanting to send a dynamic attribute that has a value which is stored in the session. The problem is that I believe that the tag library is processed before the actual jsp code is, and therefore I get something like
<%= someObj.getValue() %> instead of the actual value. Has anyone else encountered this issue and if so could you please recommend some solution(s)?
Here is how I call the taglibg:
<countytaglib:countyList state="TN" selectedCounty="<%= county %>" />
The value ends up being '<%= county %>' instead of the actual value.
Any help is appreciated. Thank you all in advance!
-PV
The required is only if the attribute is required.
For your question's answer the rtexprvalue should only be true.
in the TLD file for the TAG, for every attribute whose
value can be evaluated by the JSP scriptlet put as
follows:
<attribute>
<name>attribute_name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>rtexpvalue should be specified to true in case for the
attribute
name you would like something like
<%= user.getFirstName() %>Hope that helps.
Similar Messages
-
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()); -
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 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 -
Hi!
I cannot determine why I'm getting the following error:
I've installed Apache Tomcat/4.0.6
"PARSE error at line 6 column 19
org.xml.sax.SAXParseException: Element type "taglib" must be declared."
Can you tell why the parser does not recognize it?
Appreciate any help.
ele
[my JSP]
<%@ page language="java" import="java.lang.*,java.util.*,javax.servlet.jsp.*,java.io.PrintWriter,javax.servlet.http.HttpServletResponse,javax.servlet.jsp.JspWriter" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
[my web.xml]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>SegDis</display-name>
<description></description>
<servlet>
<servlet-name>ScriviPunto</servlet-name>
<servlet-class>ScriviPunto</servlet-class>
</servlet>
<servlet>
<servlet-name>lanciaScriviPunto</servlet-name>
<jsp-file>/lanciaScriviPunto.jsp</jsp-file>
</servlet>
<servlet>
<servlet-name>segnalazione</servlet-name>
<jsp-file>/segnalazione.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>ScriviPunto</servlet-name>
<url-pattern>/scriviPunto</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>lanciaScriviPunto</servlet-name>
<url-pattern>/lanciaScriviPunto.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>segnalazione</servlet-name>
<url-pattern>/segnalazione.jsp</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/c.tld</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
</web-app>
[the .tld file (downloaded from Sun)]
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>c</short-name>
<uri>http://java.sun.com/jstl/core</uri>
<display-name>JSTL core</display-name>
<description>JSTL 1.0 core library</description>
<validator>
<validator-class>
org.apache.taglibs.standard.tlv.JstlCoreTLV
</validator-class>
<init-param>
<param-name>expressionAttributes</param-name>
<param-value>
out:value
out:default
out:escapeXml
if:test
import:url
import:context
import:charEncoding
forEach:items
forEach:begin
forEach:end
forEach:step
forTokens:items
forTokens:begin
forTokens:end
forTokens:step
param:encode
param:name
param:value
redirect:context
redirect:url
set:property
set:target
set:value
url:context
url:value
when:test
</param-value>
<description>
Whitespace-separated list of colon-separated token pairs
describing tag:attribute combinations that accept expressions.
The validator uses this information to determine which
attributes need their syntax validated.
</description>
</init-param>
</validator>
<tag>
<name>catch</name>
<tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
<body-content>JSP</body-content>
<description>
Catches any Throwable that occurs in its body and optionally
exposes it.
</description>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>choose</name>
<tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
<body-content>JSP</body-content>
<description>
Simple conditional tag that establishes a context for
mutually exclusive conditional operations, marked by
<when> and <otherwise>
</description>
</tag>
<tag>
<name>out</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.OutTag</tag-class>
<body-content>JSP</body-content>
<description>
Like <%= ... >, but for expressions.
</description>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>default</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>escapeXml</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>if</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.IfTag</tag-class>
<body-content>JSP</body-content>
<description>
Simple conditional tag, which evalutes its body if the
supplied condition is true and optionally exposes a Boolean
scripting variable representing the evaluation of this condition
</description>
<attribute>
<name>test</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>import</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.ImportTag</tag-class>
<tei-class>org.apache.taglibs.standard.tei.ImportTEI</tei-class>
<body-content>JSP</body-content>
<description>
Retrieves an absolute or relative URL and exposes its contents
to either the page, a String in 'var', or a Reader in 'varReader'.
</description>
<attribute>
<name>url</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>varReader</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>context</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>charEncoding</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>forEach</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.ForEachTag</tag-class>
<tei-class>org.apache.taglibs.standard.tei.ForEachTEI</tei-class>
<body-content>JSP</body-content>
<description>
The basic iteration tag, accepting many different
collection types and supporting subsetting and other
functionality
</description>
<attribute>
<name>items</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>begin</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>end</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>step</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>varStatus</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>forTokens</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.ForTokensTag</tag-class>
<body-content>JSP</body-content>
<description>
Iterates over tokens, separated by the supplied delimeters
</description>
<attribute>
<name>items</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>delims</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>begin</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>end</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>step</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>varStatus</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>otherwise</name>
<tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
<body-content>JSP</body-content>
<description>
Subtag of <choose> that follows <when> tags
and runs only if all of the prior conditions evaluated to
'false'
</description>
</tag>
<tag>
<name>param</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.ParamTag</tag-class>
<body-content>JSP</body-content>
<description>
Adds a parameter to a containing 'import' tag's URL.
</description>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>redirect</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.RedirectTag</tag-class>
<body-content>JSP</body-content>
<description>
Redirects to a new URL.
</description>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>url</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>context</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>remove</name>
<tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class>
<body-content>empty</body-content>
<description>
Removes a scoped variable (from a particular scope, if specified).
</description>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>set</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.SetTag</tag-class>
<body-content>JSP</body-content>
<description>
Sets the result of an expression evaluation in a 'scope'
</description>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>target</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>url</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.UrlTag</tag-class>
<body-content>JSP</body-content>
<description>
Prints or exposes a URL with optional query parameters
(via the c:param tag).
</description>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>context</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>when</name>
<tag-class>org.apache.taglibs.standard.tag.el.core.WhenTag</tag-class>
<body-content>JSP</body-content>
<description>
Subtag of <choose> that includes its body if its
condition evalutes to 'true'
</description>
<attribute>
<name>test</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>this is a wild guess, but make sure the taglib text you added to your web.xml doens't contain funky characters you may have copied from some web page. i.e. retype it by hand if you copied it.
If that isn't it.. sorry i don't see a problem. -
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 -
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? -
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 -
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 -
Jsp taglibs and jsp commands...
Another question about taglibs...
If I want to use the body in a tag together with a class which is used in the tag code.
For example I want to do the following:
<foo:listStudents>
<%= student.fname %> <%= student.lname %> <%= student.id %>
</foo:listStudents>
Do I have to use the TagExtraInfo or? The class Student (student) is ofcourse declared and used in the tag.
Regards Per JonssonI am also on the lookout for this. i have posted many times but no one has answered my question till now. if you get to know the answer do inform me at
[email protected]
Regards
Ramesh Kesavanarayanan -
Problems with filters and jsp pages.
I have the following simple filter that checks if there is user information in the session object and redirects accordingly:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LoginFilter implements Filter
public void init(FilterConfig filterConfig) {}
public void destroy() {}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
System.out.println("filter");
HttpSession session = ((HttpServletRequest)request).getSession();
String action = request.getParameter("action");
if(action != null && !action.equals("login") && !action.equals("wronglogin"))
if(session.getAttribute("username") == null)
((HttpServletResponse)response).sendRedirect("index.jsp?action=wronglogin");
System.out.println("User not OK, kicking out...");
else
chain.doFilter(request, response);
System.out.println("User OK, letting in...");
else
chain.doFilter(request, response);
}The filter is mapped to an admin page with the name index.jsp. However, I get an error for every <% and %> tag in the file (there are quite a few) when I use the filter with the page. The page works fine without the filter, and the filter seems to work with pages without scriptlets (without the <% and %> tags). Here is the beginning of the error report:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 6 in the jsp file: /admin/index.jsp
Generated servlet error:
Syntax error on tokens, AnnotationName expected instead
An error occurred at line: 6 in the jsp file: /admin/index.jsp
Generated servlet error:
Syntax error on tokens, delete these tokens
An error occurred at line: 6 in the jsp file: /admin/index.jsp
Generated servlet error:
Syntax error on token ";", [ expected
An error occurred at line: 6 in the jsp file: /admin/index.jsp
Generated servlet error:
Syntax error on token ";", [ expected
An error occurred at line: 6 in the jsp file: /admin/index.jsp
Generated servlet error:
Syntax error on token ";", [ expected
Jasper gives me many errors per <% and %> tag. As you can see there is a <% tag on line 6. Any idea, why this does not work?
Thanks!
Message was edited by:
chincillyaWhat is the JSP scriptlet code at line 6 ?
By looking at the code we can identify if there are any syntax errors, otherwise we can't really guess what might be the problem.
Maybe you are looking for
-
Transfering iTunes library between accounts in the same computer??
Hi everyone I use my MacBook both at home and in my office. I work in a small company, so everyone is very relaxed about security. I only have one account, but recently, while at the office I discovered someone browsing at some of my kids' pictures.
-
Slow Performance with large library (PC)
I've been reading many posts about slow performance but didn't see anything addressing this issue: I have some 40000 photos in my catalog and despite generating previews for a group of directories, LR still is very slow in scrolling through the pics
-
Error using the test console of the Oracle Service Bus 11gR1
Hi I am facing a an issue while using the test console of the Oracle Service Bus 11gR1 . Every time I try to execute a business service or a proxy service I end up getting the following message. Error Accessing Test Configuration *"Test Console" serv
-
How to access music/pictures on PC through Sony Blu Ray?
I just bought and set up a Sony blu ray BDP-S570. I have connected to my wireless internet as I access Pandora & You Tube. But I want to access my music & pictures on my PC but can't make it happen. Any suggestions on how I do this? Thanks for y
-
I am on an Ipad