Jsp/java servlet architechture
i would like to ask about my design programming architechture:
because i haven't have html file,i only use jsp file to display the page.
and when the user click the button, then i call the dopost method in java file.
is it the right method to build my program??
only use jsp and java, does not has html?
SCWCD Exam Study Kit by
Hanumant Deshmukh
and Jignesh Malavia
(Manning Publications)
http://www.manning.com/deshmukh
Similar Messages
-
Problem with JSP and Java Servlet Web Application....
Hi every body....
I av developed a web based application with java (jsp and Java Servlets)....
that was working fine on Lane and Local Host....
But when i upload on internet with unix package my servlets and Java Beans are not working .....
also not access database which i developed on My Sql....
M using cpanel support on web server
Plz gave me solution...
Thanx looking forward AdnanYou need to elaborate "not working" in developer's perspective instead of in user's perspective.
-
Tomcat 6 Calling a Java Servlet from a JSP Page
Below is a very simple JSP Page that calls a Java Servlet. The question is given Tomcat security constraints, is it possible to call a servlet from a JSP and get the correct output without getting an error message? If so, how would you code the web.xml file?
c:\apache-tomcat-6.0.18
Under conf
catalina
localhost
HelloWorldExample.xml is directly under localhost
The application would have this directory structure:
webapps
HelloWorldExample
hello.jsp is directly under HelloWorldExample
Under HelloWorldExample
src
WEB-INF
classes
Under classes
jservlets
HelloWorld.java is in src folder
HelloWorld.class is in jservlets folder
HelloWorldExample.xml
<Context path="/HelloWorldExample" docBase="HelloWorldExample" debug="0"
reloadable="true" crossContext="true">
</Context>**************************
hello.jsp
<HTML>
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<FONT SIZE="4">
<P>
Please enter your name:
<FORM
METHOD="Post"
ACTION="servlet/jservlets.HelloWorld">
<TABLE BORDER="3" CELLPADDING="1" WIDTH="100%" ALIGN="CENTER">
<TR>
<TD><B>Name:</B></TD>
<TD><INPUT TYPE="text" NAME="Name" VALUE="" SIZE="65"> </TD>
</TR>
</TABLE>
<P>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</FONT>
</BODY>
</HTML>******************
HelloWorld.java
package jservlets;
import java.io.*;
import java.util.Date;
import java.util.*;
import java.text.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
PrintWriter out;
PrintWriter err;
String strName;
public void displayMessage(HttpServletRequest request, HttpServletResponse response)
throws Exception
try
if (!strName.equals("") && strName != null)
out.println("Hello " + strName + "" + "<P>");
out.println("Hello World" + "<P>");
else
out.println("Hello World" + "<P>");
catch (Exception e)
out.println("Exception: Could not display message." + "<P>");
err.println (e.getMessage () ) ;
out.println("<P>");
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
try
response.setContentType("text/html");
out = response.getWriter();
err = response.getWriter();
strName = request.getParameter("Name").trim();
out.println("<html><head><title>");
out.println("</title></head><body>");
out.println("<FORM");
out.println("METHOD=POST");
out.println("ACTION=http://localhost:8080/HelloWorldExample/hello.jsp>");
out.println("<TABLE ALIGN='RIGHT'>");
out.println("<TR>");
out.println("<TD>");
out.println("<INPUT TYPE=\"SUBMIT\" VALUE=\"Hello World Page\";>");
out.println("</INPUT>");
out.println("</TD>");
out.println("</TR>");
out.println("</TABLE>");
out.println("</FORM>");
out.println("<BR CLEAR='all'>");
out.println("<P>");
displayMessage(request, response);
out.close();
out.println("</body></html>");
catch(Throwable e)
e.printStackTrace();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
doPost(request, response);
web.xml
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>jservlets.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping> ******************************
HelloWorld.java can be compiled by using javac.
Once compiled, HelloWorld.class would be moved to the jservlets folder.
FYI, coding the above url-pattern results in:
HTTP Status 404
The requested resource (/HelloWorldExample/servlet/jservlets.HelloWorld) is not available
The following url-pattern in the web.xml file permits the servlet to be executed but results in a null pointer exception:
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/ </url-pattern>
</servlet-mapping> **************************************************
RobinThis problem was resolved.
In hello.jsp
ACTION="servlet/jservlets.HelloWorld">
was replaced with
ACTION="servlet/HelloWorld">
Robin -
Location of java servlet (not jsp) deployed on Java Stack
Hello,
Why this forum? this post is related to the way of calling a java servlet deployed on the java stack, so it's related to the structure of the stack than to real java programming.
Usually, I develop JSP servlets which are easily called either with a mapping or not. I have deployed now a java servlet and added a mapping to it by modifying the xml source itselft in its descriptor, but after deployement I am not able to reach the resource.
In the windows explorer of the java stack I find in j2ee>cluster>server>apps my application as follows:
app_ear>servlet_jsp>app>root>WEB-INF>classes>my class files
app_ear>servlet_jsp>app>root>app.jsp
This time it's not a jsp that I want to call: app/app.jsp but my java servlet which lies in the classes subdir.
Could someone help my to achieve this or is it the wrong way, we can only request jsp applications?
Kind regards,
Tanguy MezzanoHi Vladimir,
here's my web.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>WEB APP</display-name>
<description>WEB APP description</description>
<servlet>
<servlet-name>SSORedirect3.jsp</servlet-name>
<jsp-file>/SSORedirect3.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>AuthenticatorServlet</servlet-name>
<url-pattern>/SSOredirect3</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>SecurityConstraint</display-name>
<web-resource-collection>
<web-resource-name>WebResource</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>DefaultSecurityRole</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>DefaultSecurityRole</role-name>
</security-role>
</web-app>
And in my jsp file, I have a form with this kind of code:
<form name="xyz" method="GET" action="http://j2eeserver:50000/SSOredirect3/SSOredirect3">
I get this error in my logs:
com.sap.engine.services.servlets_jsp.server.exceptions.ServletNotFoundException: Requested resource [SSOredirect3/servlet/AuthenticatorServlet] not found.
Exception id: [000C299F469E00650001D8E900000CCC000458E27823275B]#
Best regards,
Tanguy Mezzano -
Questions about Java Servlets and JSP
Hi,
I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
I have a few questions:
How should I start to learn JS and JSP?
How applicable will the java knowlegdge I have already be?
Are JSP common on the world wide web?
What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
Is it likey my web host (and others) will support JSP?
Thank-you very much for helping a novice get started,
Regards,
PaulHi, Steve ...has to be frustrating! But do not despair.
Let's suppose the servlet it's named MyServlet on package org.servlets
WEB-INF should look:
WEB-INF
classes
org
servlets
MyServlet.class
web.xml
web.xml file should have this two declarations:
<web-app>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>org.servlets.MyServlet</servlet-class>
</servlet>
<!-- other servlets -->
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
<!-- other servlets mappings -->
</web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing. -
I have a small hosting company and was wondering what is required to be installed on a Win2k Server to host Java Servlets and JSP pages for a client of mine?
Ah, so you just want to add a servlet engine to IIS5?
Tomcat can be used as a plugin for IIS. Check out the Tomcat FAQs - somewhere in there you should find one relating to using Tomcat as an IIS plugin. They're far more comprehensive than I could ever hope to be on the matter! -
Is it true that JSP creates Servlet java code?
I am working with JSP.
My web server is tomcat.
Is it true that JSP creates Servlet java code of JSP files when it executes? If so how can I view them?Yes..it is true..
to find out..do this..
on purpose leave a bug in ur jsp that will generate a compilation error. So in ur browser some exception will be shown.That exception message will have the clue to the java file (e.g
error in compiling _XYZ.java).You can manually search for this file..
(If the copilation is successful, then this java file is deleted by the server.) -
Need Help Badly on Shopping Cart Using JSP And Java Servlet
Hi All,
This is the 1st time i am trying to create a shopping cart using JSP and Servlet.
I have read through a few acticles but i still do not get the whole idea of how it works.
Please guide me as i need help very badly.
Thanks.
This is one of the jsp page which displays the category of products user would like to buy : Products.jsp
<html>
<head>
<title>Purchase Order</title>
</head>
<body topmargin="30">
<table border="0" width="100%" id="table1" cellpadding="2">
<tr>
<td bgcolor="#990000" width="96">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Code</font></b></td>
<td bgcolor="#990000" width="260">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Description </font></b></td>
<td bgcolor="#990000" width="130">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Brand
</font></b></td>
<td bgcolor="#990000" width="146">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">UOM
</font></b></td>
<td bgcolor="#990000" width="57">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Unit<br>
Price </font></b></td>
<td bgcolor="#990000" width="62">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Carton<br>
Price </font></b></td>
<td bgcolor="#990000" width="36">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Qty</font></b></td>
<td bgcolor="#990000" width="65">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Add<br>
To Cart</font></b></td>
</tr>
<tr>
<td align="center" width="96" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">123</font>
</td>
<td align="center" width="260" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">Tom Yam</font>
</td>
<td align="center" width="130" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nissin</font>
</td>
<td align="center" width="146" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">12 x 10's</font>
</td>
<td align="center" width="57" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">$3.85</font>
</td>
<td align="center" width="62" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">$46.2</font>
</td>
<td align="center" width="36" bgcolor="#CCCCCC">
<!--webbot bot="Validation" S-Data-Type="Integer" S-Number-Separators="x" -->
<p align="center"><input type="Integer" name="Q10005" size="1"></p>
</td>
<td align="center" width="65" bgcolor="#CCCCCC">
<p><input type="checkbox" name="checkbox" value="123"></p>
</tr>
<tr>
</table>
<table border="0" width="100%" id="table2">
<tr>
<td>
<div align="right">
<input type="hidden" name="hAction" value="AddToCart"/>
<input type=submit name="submit" value="Add To Cart"/>
</div>
</td>
</tr>
</table>
</body>
</html>
After user has make his selection by entering the qty and ticking on the check box, he would click the "Add To Cart" button ... and this would call my servlet : AddToAddControlSerlvet.java
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
public class AddToCartControlServlet extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
String action = req.getParameter("hAction");
if (action.equals("AddToCart"))
addToCart(req,res);
public void addToCart(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
try
String url = "";
String[] addList = req.getParameterValues("checkbox");
HttpSession sess = req.getSession(true);
//String sessionID = sess.getId();
DBClass dbClass = new DBClass();
ArrayList cartList = new ArrayList();
for (int i = 0; i < addList.length; i++)
String productCode = (String)addList;
int qty = Integer.parseInt(req.getParameter("Q"+productCode));
Products product = dbClass.getProductDetail(productCode);
double totalUnitAmt = qty * product.getUnitPrice();
double totalCartonAmt = qty * product.getCartonPrice();
Order order = new Order(product.getProductCode(),product.getProductDesc(),product.getBrandName(),product.getUom(),qty,product.getUnitPrice(),product.getCartonPrice(),totalUnitAmt,totalCartonAmt);
cartList.add(order);
sess.setAttribute("cartList", cartList);
url = "/Cart/CartDetails.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, res);
catch (Exception e)
System.out.println(e);
From here, i would get the list of items which user has selected and add to the cartList, then i would direct the user to CartDetails.jsp which displayed the items user has selected.
From there, user would be able to remove or to continue shopping by selecting other category.
How i do store all the items user has selected ... everytime he would wan to view his cart ...
As i would be calling from jsp to servlet .. or jsp to servlet ... and i do not know how i should go about in creating the shopping cart.Hi !
Yon can use a data structure as vector and store the items selected by the user into the vector . Keep the vector in session using session object , so the user can access the entire shopping cart from anywhere in the application .
Then , you can change the cart accordingly .
Hope this works.
Cheers ,
Pranav -
We are in the stage of deciding which language to develop portlets. I lean towards JSP or servlets for the wide array of Java libraries we can use. I think the only advantage of PL/SQL is speed. Thanks.
It depends. If your developers are mainly Java developers, you'll probably prefer building web portlets. But if you have a strong PL/SQL skill set you could choose the latter. Additionally, if you're developing content that is database intensive you may want to build PL/SQL portlets since they transact with the database faster. If you're going to aggregate content from various web sites, using web providers is preferable. It's a matter of choice based on your requirements and preferences.
-
JSPs and Servlets do not work on Apache HTTP- Procesor Intel P4
Computer description: Intel Pentium 4 processor with 20GB HD
drive, 1GB RAM, Windows 2000Pro, Service pack II
Before installation:
We created a temporary directory on our Intel Pentium. 4
processor server (e.g. \TEMP).
Copied the contents of the Oracle* Server CD to the temporary
directory.
Renamed each copy of the SYMCJIT.DLL to SYMCJIT.OLD.
Set the java_compiler=none environment variable.
Installation:
We run the SETUP.EXE from the \TEMP\install\win32 directory and
install Oracle 8.1.7 EE Rel 3 Typical
Configuration tool Net8 Configuration Assistant succeeded
Configuration tool Oracle Database Configuration Assistant
succeeded
Configuration tool Starting Oracle HTTP service: 7 times error
message (java.exe has generated errors and will be closed by
Windows, You will need to restart the
program, An error log is being created)
HTTP server responses.
All Java programs do not respond (e.g. IsItWorking does not work)
After installation:
Open the jserv.conf file chack that ApJServManual is set to Off.
set ApJServLogLevel debug (will give more informative errors for
debugging)
set ApJServDefaultHost www.in.oracle.com (to your machine name
with the
domain name or IP address)
set ApjServDefaultPort 80000
Open the jserv.properties files and make the following changes:
bindaddress=www.in.oracle.com (Same name as ApJServDefaultHost
in jserv.conf)
port=80000 (same port as in the jserv.conf)
Enable all log options in jserv.properties:
log=true
log.file=/usr/local/apache/var/log/jserv.trace
log.timestamp=true
log.dateFormat=[yyyyMMdd HHmmss:SSS]
log.channel.init=true
log.channel.terminate=true
log.channel.serviceRequest=true
log.channel.authentication=true
log.channel.requestData=true
log.channel.responseHeaders=true
log.channel.signal=true
log.channel.exceptionTracing=true
log.channel.servletManager=true
Java servlets and JSP still do not redspond.
If we try to start HTTP server from Windows service, we always
get message: unable to locate dll: The dynamic link
library Perl.dll could not be found in the secified path (our
path: C:\oracle\ora81\bin;C:\oracle\ora81\Apache\Perl\5.00503
\bin\mswin32-x86;
C:\Program Files\Oracle\jre\1.1.7
\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;) and
error message: Could not start
OracleOraHome81HTTPServer service on local computer. The service
did not respond to the start or control request in a
timely fashion.
Starting Oracle HTTP service from Start/Programs/Oracle: 7 times
error message (java.exe has generated errors and will be closed
by Windows, You will need to restart the
program, An error log is being created)
We tested also modifications of oraparam.ini
a. Copy only the install directory from the CD to the hard
disk ,say, e:\temp.
b. Open oraparam.ini and make the following modifications
(Assuming CD
drive is f:)
* Change the "SOURCE=" line to use the full path to the CD
instead of a
relative path. (i.e., SOURCE=f:\stage\products.jar)
* Change the "JRE_LOCATION" line to use the full path to the CD
instead of a
relative path. (i.e.,
JRE_LOCATION=f:\stage\Components\oracle\swd\jre\1.1.7\1
\DataFiles\Expanded)
* Change the "OUI_LOCATION" line to use the full path to the CD
instead of a
relative path. (i.e.,
OUI_LOCATION=f:\stage\Components\oracle\swd\oui\1.6.0.9.0\1
\DataFiles\Expanded
* Change the "JRE_MEMORY_OPTIONS" line to add "-nojit" as the
first argument.
(i.e., JRE_MEMORY_OPTIONS=-nojit -ms16m -mx32m)
^^^^^^
* Other entries should remain the same
c. Launch setup.exe from the temporary location on your hard
drive (i.e.
e:\temp\install\ win32\setup.exe). This will use the modified
oraparam.ini and pick up the information from the CD since the
absolute
locations are specified.
After that modification of oraparam.ini, the HTTPServer does not
respond at all.
So we undo changes on oraparam.ini and reinstall HTTP.
We copied SYMCJIT.DLL and jvm.dll from JDK 1.1.8_008 to
Apache\jdk\..
Since then at least the demo IsItWorking responses, but database
connection can not be established. But jsp demo still do not?
THX in advance
NejaI'm still having problems with Portal config (as part of 9iAS) on
a P4 but i have cleared the hurdle of the HTTP listener (i
think).
I downloaded and installed the JRE that is P4 compatible from
www.sun.com (it puts it under c:\program files)
then overwrote all the files in the jre directories in the cd
staging area with the files from Sun (i.e. all symcjit.dll
locations). I also had to put a file "javai.dll" in the same
directory as the file "java.exe". This got the install all
working.
The service will fail first time because the install creates
another set of incompatible jre files. You must again search for
symcjit and repeat the above procedure.
You must also overwrite the files in the c:\program
files\oracle\inventory\jre directories (sorry cant remember exact
path).
Hope this helps.
Mark Gornicki
PS if anyone knows why Portal config hangs at 67%
(before/during/after processing "bulkload.jar" section) please
let me know :-) -
Deploying a WAR file containing .jsp and servlets (also uses JNI)
Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
Server documentation on deploying such files.
This is how we went about it:
1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
Server.
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
and
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
(We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
service packs)
From browser, open http://yourserver:8888/
Click on Select a Server:Manage
Click on Virtual Server Class
Click on https-yourserver
Click on the Web Applications Tab
Then, click on Deploy Web Application
Enter the following -
WAR File On: Local
WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Application URI: /jakarta
Installation Directory: c:\iPlanet\examples\jakarta-examples
By clicking on OK it deployed the application.
I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
Edit /jakarta c:/iPlanet/examples/jakarta-examples
Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
- [images]
- [jsp]
- index.html
- [servlets]
- [META-INF]
- [WEB-INF]
- [classes]
- [tlds]
- web.xml
- index.html
I restarted the server and accessed it using the following URL from my IE browser:
http://yourserver/jakarta/index.html
Then I clicked on the JSP Examples and tried some JSP examples.
b) Alternatively, you can also deploy the same example from the command-line.
Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
wdeploy deploy -u /jakarta
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\jakarta-examples
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Restart the web server (I don't think you have to restart, but .. might as well).
2)Deploy your web-application
My Foo.war has the following structure.
You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
in your PATH)
Foo.war
- [META-INF]
- [WEB-INF]
- web.xml
- [classes]
- Bar.class
- MoServlet.class
- [lib]
- ThirdParty.jar
- [natlib]
- extlib.dll
- foo.jsp
Here is our application scenario:
foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
Now to deploy it, do the following:
(a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
JSP compile error).
<%@page language="java" import="Bar" contentType="text/html"%>
(b) Check web.xml (for Servlets)
Within web.xml, make sure you have the following mappings:
<servlet>
<servlet-name> MoLink </servlet-name>
<servlet-class> MoServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> MoLink </servlet-name>
<url-pattern> /servlet/Mo </url-pattern>
</servlet-mapping>
(c) Deploy the application
Using command line:
wdeploy deploy -u /foo
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\foo-dir
Foo.war
(d) Change web-apps.xml file (for picking up ThirdParty.jar)
It is located in
C:\iPlanet\Servers\https-yourserver\config
You should see something similar to following after successful deployment.
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
Change it to look like following to pick up the ThirdParty.jar
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
<class-loader reload-interval="300"
classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
delegate="false"/>
</web-app>
(e) Change jvm12.conf file (for JNI)
It is located in
C:\iPlanet\Servers\https-yourserver\config
Add or uncomment the following lines:
#optional - just helps with instrumenting the jsp and servlet code
jvm.include.CLASSPATH=1
jvm.enableDebug=1
nes.jsp.enabledebug=1
jvm.trace=7
jvm.verboseMode=1
#required for JNI
java.compiler=NONE
jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
jvm.option=-Xrs
jvm.option=-Xnoagent
# not sure if this is needed for iPlanet web server
jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
(f) Change magnus.conf file (for JNI)
We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
in Path, it didn't work.
Change Extrapath directive:
ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
to
ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
(g) Apply changes from the Web Server Administration Console and Restart the web server.
You should be able to see the behaviour that you want from your application.
http://yourserver/foo/foo.jsp
Hope this was helpful!!!
SonuDeploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
Server documentation on deploying such files.
This is how we went about it:
1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
Server.
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
and
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
(We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
service packs)
From browser, open http://yourserver:8888/
Click on Select a Server:Manage
Click on Virtual Server Class
Click on https-yourserver
Click on the Web Applications Tab
Then, click on Deploy Web Application
Enter the following -
WAR File On: Local
WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Application URI: /jakarta
Installation Directory: c:\iPlanet\examples\jakarta-examples
By clicking on OK it deployed the application.
I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
Edit /jakarta c:/iPlanet/examples/jakarta-examples
Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
- [images]
- [jsp]
- index.html
- [servlets]
- [META-INF]
- [WEB-INF]
- [classes]
- [tlds]
- web.xml
- index.html
I restarted the server and accessed it using the following URL from my IE browser:
http://yourserver/jakarta/index.html
Then I clicked on the JSP Examples and tried some JSP examples.
b) Alternatively, you can also deploy the same example from the command-line.
Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
wdeploy deploy -u /jakarta
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\jakarta-examples
C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
Restart the web server (I don't think you have to restart, but .. might as well).
2)Deploy your web-application
My Foo.war has the following structure.
You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
in your PATH)
Foo.war
- [META-INF]
- [WEB-INF]
- web.xml
- [classes]
- Bar.class
- MoServlet.class
- [lib]
- ThirdParty.jar
- [natlib]
- extlib.dll
- foo.jsp
Here is our application scenario:
foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
Now to deploy it, do the following:
(a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
JSP compile error).
<%@page language="java" import="Bar" contentType="text/html"%>
(b) Check web.xml (for Servlets)
Within web.xml, make sure you have the following mappings:
<servlet>
<servlet-name> MoLink </servlet-name>
<servlet-class> MoServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> MoLink </servlet-name>
<url-pattern> /servlet/Mo </url-pattern>
</servlet-mapping>
(c) Deploy the application
Using command line:
wdeploy deploy -u /foo
-i yourserver
-v https-yourserver
-d c:\iplanet\examples\foo-dir
Foo.war
(d) Change web-apps.xml file (for picking up ThirdParty.jar)
It is located in
C:\iPlanet\Servers\https-yourserver\config
You should see something similar to following after successful deployment.
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
Change it to look like following to pick up the ThirdParty.jar
<web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
<class-loader reload-interval="300"
classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
delegate="false"/>
</web-app>
(e) Change jvm12.conf file (for JNI)
It is located in
C:\iPlanet\Servers\https-yourserver\config
Add or uncomment the following lines:
#optional - just helps with instrumenting the jsp and servlet code
jvm.include.CLASSPATH=1
jvm.enableDebug=1
nes.jsp.enabledebug=1
jvm.trace=7
jvm.verboseMode=1
#required for JNI
java.compiler=NONE
jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
jvm.option=-Xrs
jvm.option=-Xnoagent
# not sure if this is needed for iPlanet web server
jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
(f) Change magnus.conf file (for JNI)
We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
in Path, it didn't work.
Change Extrapath directive:
ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
to
ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
(g) Apply changes from the Web Server Administration Console and Restart the web server.
You should be able to see the behaviour that you want from your application.
http://yourserver/foo/foo.jsp
Hope this was helpful!!!
Sonu -
Getting to next JSP from Servlet
I am getting a 404 when I try to redirect from my servlet to an error page. The code that I am testing is....
catch (SQLException es)
LOG.error("Unexpected error in Login.createUser.Error
message = " + es);
session.setAttribute(Constants.MESSAGE, es.getMessage());
session.setAttribute(Constants.ERROR_TITLE, "Login error: " + Constants.SQL_ERROR);
resp.sendRedirect(Constants.ERROR_PATH);
I have a compiled java class called Constants where the ERROR_PATH is defined as
/** Constant name used in obtaining the path to the error page. */
public static final String ERROR_PATH = "/Jsp/error.jsp";
My JSP pages are located at the root...
myapp
....Jsp
....WEB-INF
........classes
My web.xml looks like this
<servlet>
<servlet-name>errorPage</servlet-name>
<jsp-file>/Jsp/errorPage.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>error</servlet-name>
<url-pattern>/Jsp/error.jsp</url-pattern>
</servlet-mapping>
Can anyone point me in the right direction....ThanksI tend to use a utility method called redirectToResource in particular to redirect from any servlet to any JSP :
/** This method will still work when the server is configured to
* listen to port 80 rather than port 8080 (default in Tomcat)
public void redirectToResource (HttpServletRequest req,
HttpServletResponse resp,
String resourceName)
throws ServletException, IOException
int serverPort = req.getServerPort();
String scheme = req.getScheme();
String serverName = req.getServerName();
StringBuffer urlBuffer = new StringBuffer(40);
urlBuffer.append(scheme + "://" + serverName);
urlBuffer.append(":" + serverPort);
urlBuffer.append(resourceName);
String location = resp.encodeRedirectURL(urlBuffer.toString());
resp.sendRedirect(location);
} -
Hi friends,
[please forgive me if i am posting this in the wrong forum, all seems same to a fresher]
Now, to my problem..i need a suggestion, a way or a method to implement the following!
I am supposed to create a servlet that reads data from oracle database. Once i retrive the data (for example: 6 rows of a table having 4 attributes), i am supposed to pass this data to a JSP page where the data has to be formatted and displayed properly. If i call the same servlet from a different JSP, i should be able to access the data in that JSP and format it in a different way. How do i pass the data to JSP? what method i can use to achieve this task?
Note: I already know about PrintWriter pw = response.getWriter(); and then printing the formated HTML page..but i want to keep the formatting to JSP part and send only the data part that i can access in JSP
Thanks in adavancearun_ramachandran wrote:
[please forgive me if i am posting this in the wrong forum, all seems same to a fresher]Then you should learn to be more observant - after all, we have JSP and Servlet fora, further down the list. :)
I am supposed to create a servlet that reads data from oracle database. Once i retrive the data (for example: 6 rows of a table having 4 attributes), i am supposed to pass this data to a JSP page where the data has to be formatted and displayed properly. If i call the same servlet from a different JSP, i should be able to access the data in that JSP and format it in a different way. How do i pass the data to JSP? what method i can use to achieve this task? You can store the data in your session object. You can even use JavaBeans and the jsp:usebean tag.
[http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html]
Note: I already know about PrintWriter pw = response.getWriter(); and then printing the formated HTML page..but i want to keep the formatting to JSP part and send only the data part that i can access in JSPA wise approach - I wish more prople woiuld be as thoughtful. -
How can I include a portal component look and feel in a java servlet
Does any body know how can i include a portal component look and feel (tables, buttons, etc) in a java servlet?
Hi José,
I don't think that is possible. But you can import the css files that ep uses for its look and feel and try to give your web pages similar look and feel. The tables and other controls used in EP are totally different and are done through complex JavaScript coding instead of simple HTML tags. If you want exact lok and feel then i thin you must go for a Webdynpro based application rather then a J2EE application with JSPs.
Regards,
Guru.
PS: Give points for helpful replies. -
Deploying web applications - jsp generated servlet's may be written over the same file!
Hi, I have made the following test:
Created two simple web applications with one jsp page, and deployed it
with different context names, in weblogic.properties I have:
weblogic.httpd.webApp.weirdApp=\java\weblogic\myserver\weirdApp.war
weblogic.httpd.webApp.weirdAppTwo=\java\weblogic\myserver\weirdAppTwo.war
(Note: I have used two diferent war files, because I have a different
implementation of the jsp page, I could have used the same warfile, and
deployed it two times with the same different names I have used)
These two applications have a jsp named myHomePage.jsp
If I access the first application, like this:
http://myServer:7001/weirdApp/myHomePage.jsp
the servlet for myHomePage is created in
/java/weblogic/myserver/WEB-INF/_tmp_war/jsp_servlet/_myhomepage.class
If I access the second application, like this:
http://myServer:7001/weirdAppTwo/myHomePage.jsp
the servlet for myHomePage is created in
/java/weblogic/myserver/WEB-INF/_tmp_war/jsp_servlet/_myhomepage.class
It overrides the first one! Because the servlets are keeped in memory by
a different class loader this seems to not affect the other servlet, but
I am wondering what may happen with this strange beaver from weblogic!
Bruno Antunes,
Java Software Engineer
email: mailto:[email protected]
Phone: +351.21.7994200
Fax : +351.21.7994242
WhatEverSoft - Java Center
Centro de Competencia Java
Praca de Alvalade, 6 - Piso 4
1700-036 Lisboa - Portugal
URL: http://www.whatevernet.com
****************** Internet Mail Footer ****************************
A presente mensagem pode conter Informação considerada Confidencial.
Se o receptor desta mensagem não for o destinatário indicado, fica
expressamente proibido de copiar ou endereçar a mensagem a terceiros.
Em tal situação, o receptor deverá destruir a presente mensagem e
por gentileza informar o emissor de tal facto.
Privileged or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message,
you may not copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by
reply email.I have a separate java class that gets my data and returns a Result object. Do you mean java.sql.ResultSet?
In my main servlet I do the following:
request.setAttribute("supporttracker",
supporttracker.findsupporttracker(monthYear));
and then in my JSP I can iterate through the Result
like the following with no problems:
<c:forEach var="supporttracker" begin="0"
items="${supporttracker.rows}" varStatus="counter">
My problem is that I can only iterate through this
once in the page whereas I have no problem doing
multiple forEach loops through other types of
lists/collections such as an ArrayList. Right, because a ResultSet is a database cursor and doesn't act the same way that an ArrayList does. It's more like an InputStream - once you read it, you close it. If you want to re-read it, you have to re-initialize it again.
Iterators behave that way, too. Once you walk through them, you have to re-initialize them.
I've looked
on the web and in a couple of books, I first thought
it may be scope or some attribute in forEach that I
was missing but I'm stumped. It seems like it's
because the pointer to the result set is at the end
of the result set when trying the second iteration,
but I thought by using the begin="0" would put the
pointer at the first row again, on my second
iteration I'm getting no rows/data outputed.
Please help and thanks in advance!The better thing to do is for your method to return a List of objects, one per row, that represent what the ResultSet returns. Have that method iterate through the ResultSet, loading the rows into the List, and close it before you leave in a finally block. A database cursor is a scarce resource, so it's a good idea to close it as soon as you can.
%
Maybe you are looking for
-
Error while posting Payload from MII to PI
<?xml version="1.0" encoding="UTF-8"?> <p1:UpdateControlRecipeStatus_Async_V01 xmlns:p1="http://bhpbilliton.net/services/ControlRecipe" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:p2="http://bhpbilliton.net/GDT" xmlns:xsi="http://www
-
Xi-Fi Fatal1ty update , software no longer works
just bought fatality card and installed with drivers /software of cd, then went to creatives site and downloaded newest driver 2.07.004 released 5//05, now none of the software works, stating audio device incompatible!, tried rebooting and also reins
-
Hi, im using itunes store and i bought some songs and apple send me a email, and it says it was a receipt. It also said that its bill to : Store credit, and the total of the order is 1.98 $. So do i have to pay this or its just a proove of purchase ?
-
When I select/tick Apple TV on the ipod I get no 'Done' button so cannot mirror to tv. I have latest IOS software. Any suggestions?
-
Sql Plus worksheet (oemapp) won't start without admin rights in Oracle 9.2
My organization is removing users local admin rights on their Windows XP Professional systems. I have been tasked with enabling SQLPlus worksheet to run with power user rights. I have granted full control to all of the files on the C drive, and spent