You need to sign in to do that
Don't have an account?
DJH
Making sense of jsp-sample
I'm pretty new to JSPs so that may be part of my problem, here, but there's no documentation at all on how one should tie the pieces of the "jsp-sample" together to make a working JSP application. They don't seem to relate to each other.
First of all, session.jsp is 100% Java, no HTML content. Why? Shouldn't its content be somewhere else instead? Also, it doesn't seem to be invoked by anything.
Secondly, GettingStartedEclipse.html. What's this for?
Thirdly, when I attempt to use login.jsp by entering a username and password and clicking the login button, what I get is "No file exists at the address "Salesforce/jsp-sample/Web Root/button cause an action to go out and attempt to login to the Salesforce web service?
I was hoping this JSP example was basically a JSP version of the straight-Java Quickstart example but it's not. Is there such an animal?
Please help....
DJH
First of all, session.jsp is 100% Java, no HTML content. Why? Shouldn't its content be somewhere else instead? Also, it doesn't seem to be invoked by anything.
Secondly, GettingStartedEclipse.html. What's this for?
Thirdly, when I attempt to use login.jsp by entering a username and password and clicking the login button, what I get is "No file exists at the address "Salesforce/jsp-sample/Web Root/button cause an action to go out and attempt to login to the Salesforce web service?
I was hoping this JSP example was basically a JSP version of the straight-Java Quickstart example but it's not. Is there such an animal?
Please help....
DJH
Message Edited by DJH on 09-24-2004 05:09 PM
Your are right that the jsp-sample could use a lot more (or any!) documentation.
As it is currently packaged, the jsp-sample is an Eclipse project, which means it is designed for use with the Eclipse IDE. Eclipse isn't, however, nessesary, as long as you get the filenames/paths correct. (Are you using an IDE?) Its not immediately clear to me what your error is given the description..
..included in the jsp-sample is all of the session management nessesary to bind a sforce login to a JSP sessions (its very useful, trust me.) The session.jsp is included at the top of the sample jsp pages (and any other jsp pages you write), and makes sure the login is correct, bounces the user to the login page if not, etc..
..if you are building any type of JSP/sforce app, its worth investing the time to get the sample working - I'll be doing a whole session around this sample & JSP at dreamforce, so you might want to consider attending the conference as well!
Thanks for the reply. I'm glad to hear that you're going to be covering the JSP sample in detail, but November (DreamForce) is too late for me! I need to get going with Salesforce in JSP session style this week.
I can use Eclipse; I have used it a few times and I have everything (Axis 1.1, Tomcat, etc.) installed. I have also successfully built and run the Salesforce 4.0 Quickstart using my company's WSDL. Could you summarize the proper steps to set up the JSP sample project in Eclipse? I'm on Mac OS X, in case it matters.
DJH
..if you don't want to go the Eclipse route, I've created a WAR file of the sample and attached it to this message; this should install into your Tomcat server automatically. From there, just duplicate and edit the test.jsp to taste - the rest should be handled for you. Note you may need to but the Axis libs in the classpath or your JRE's trusted lib dir (I forget what dir that is on Mac OS X..)
..let us know how it goes.
I installed the WAR file in Tomcat's webapps directory and started Tomcat. In my web browser I entered the URL for the login JSP, and it displayed just fine. I entered my username and password and clicked the login button. I got a 404 Not Found on index.jsp. It's right, there is no index.jsp. Is it intentionally missing?
So then I entered the URL for the test JSP, and I got a 500 exception report:
-----Cut here-----
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 48 in the jsp file: /test.jsp
Generated servlet error:
[javac] Compiling 1 source file
/Library/Tomcat/work/Standalone/localhost/jsp-sample/test_jsp.java:155: cannot access org.apache.axis.client.Stub
file org/apache/axis/client/Stub.class not found
QueryResult qr = sforceLogin.getBindingStub().query("select firstname, lastname, company, email from lead");
-----End cut-----
Same thing for session.jsp, BTW.
I have defined my classpath environment variable to include all the Axis jars, so why aren't the classes being found?
Two things to try:
from your $TOMCAT_HOME/webapps/jsp-sample dir, create /WEB-INF/lib, and put the Axis libs in that dir.
OR
Put the JARs in /Library/Java/Extensions/, where they will be automatically accessable to any Java process. (See http://developer.apple.com/documentation/Java/Conceptual/Java141Development/Overview/chapter_2_section_4.html for details)
..and yes, change postTarget to test.jsp (or just pass test.jsp into login.jsp..
String postTarget = request.getParameter("postTarget");
if (postTarget==null) {
postTarget="index.jsp";
}
OK, I created the /WEB-INF/lib directory and copied the Axis jars into it, and also fixed the login.jsp. Now I get this upon hitting the login button on the login page:
java.lang.NullPointerException
at org.apache.jsp.test_jsp._jspService(test_jsp.java:131)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
....
WRT the location of the Axis jars: WebObjects ships with Axis 1.0, and the jars are in /Library/WebObjects/Extensions. So that's why installed the Axis 1.1 jars there. I've put out an inquiry on another mailing list as to whether the Axis jars should go in /Library/Java/Extensions instead, and if so, whether this was an oversight by Apple or what.
DJH
..I'd start by making a test page/modifying test.jsp to see if you are being logged in correctly.
..i'm guessing that the WebObjects stuff won't be a problem as its out of the regular Java path..
if (session.isNew()) {
count=1;
session.putValue("session_count",new Integer(count));
} else {
count = ((Integer)session.getValue("session_count")).intValue();
count++;
session.putValue("session_count",new Integer(count));
}
Well, session.getValue("session_count") is returning null. I changed the code to look like this:
if (session.isNew()) {
count=1;
session.putValue("session_count",new Integer(count));
} else {
if (session.getValue("session_count")!=null) {
count = ((Integer)session.getValue("session_count")).intValue();
count++;
session.putValue("session_count",new Integer(count));
} else {
System.out.println("session count is null--now what?");
}
}
And ran again, and I got the "session count is null-now what?" message in the console, and the test page finally displayed nicely.
So, what's the deal with the null value? Is this expected, and if so, why doesn't the sample code around it as I did?
DJH
..that code exists to make sure that sessions are in fact being created - deleting it is fine, but if sessions aren't working correctly, you'll run into issues later..
DJH