Muliple servlets on a frames page.
Hi,
My application functions as such...My initial page is an html form which takes in a username and password which when submitted opens up a a jsp page with 8 frames on it. The form will be replaced by the jsp page. Each frame has a servlet as its source.
This is how I made each of the servlets the source of each of the frames
<frameset cols="50%,50%">
<frame name="11" src="servlet/GetMyProjects" target="_self">
<frame name="16" src="servlet/GetWorkflow" target="_self">
</frameset>
My problem is that the initial form will have many hidden fields along with the username and password supplied by the user which need to be passed to the servlets via a doPost.
I am able to extract the parameters from the HttpRequest object in my JSP page but dont quite know how to pass it back to the other servlets invoked by the jsp.
anyhelp would be well appreciated.
thnx
Before you implement the frames in your jsp, set the attributes with something like this - application.setAttribute("password",pwd);
When you want to use these variables in the servlets get them by using
getServletContext().getAttribute("password");
Similar Messages
-
3-Frame page, FND_COOKIE_HAS_NO_ICX_ENTRY
Hello
I have a 3-Frames page according to the OAF Developers guide.
When I run it on the program it works great; but when I run it on the server the page throws this error:
oracle.apps.fnd.framework.OAException: Application: FND, Message Name: FND_COOKIE_HAS_NO_ICX_ENTRY.
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1227)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1959)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:501)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:422)
at oa_html._OA._jspService(_OA.java:88)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
at org.apache.jserv.JServConnection.run(JServConnection.java:294)
at java.lang.Thread.run(Thread.java:534)
## Detail 0 ##
oracle.apps.fnd.framework.OAException: Application: FND, Message Name: FND_COOKIE_HAS_NO_ICX_ENTRY.
at oracle.apps.fnd.framework.webui.OAJSPHelper.getIcxCookie(OAJSPHelper.java:293)
at oracle.apps.fnd.framework.webui.OAJSPHelper.getIcxCookie(OAJSPHelper.java:241)
at oracle.apps.fnd.framework.webui.OAPageBean.createRFURL(OAPageBean.java:5997)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:716)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:501)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:422)
at oa_html._OA._jspService(_OA.java:88)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
at org.apache.jserv.JServConnection.run(JServConnection.java:294)
at java.lang.Thread.run(Thread.java:534)
oracle.apps.fnd.framework.OAException: Application: FND, Message Name: FND_COOKIE_HAS_NO_ICX_ENTRY.
at oracle.apps.fnd.framework.webui.OAJSPHelper.getIcxCookie(OAJSPHelper.java:293)
at oracle.apps.fnd.framework.webui.OAJSPHelper.getIcxCookie(OAJSPHelper.java:241)
at oracle.apps.fnd.framework.webui.OAPageBean.createRFURL(OAPageBean.java:5997)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:716)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:501)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:422)
at oa_html._OA._jspService(_OA.java:88)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
at org.apache.jserv.JServConnection.run(JServConnection.java:294)
at java.lang.Thread.run(Thread.java:534)
Any idea of what is happening or how to fix it??
Thanks
JairoLOOKING AT THE ERROR AGAIN I THINK YOU ARE FACING A PROBLEM WITH THE DBC
set the Profile System option
'Applications Database ID'
to aliasname_SID(do not include the .dbc extension).
This overrides the specified DBC file in properties files, which is picked up
for database connectivity at runtime.
Workaround 2--
1. If machine name is dolphins and alias is dolphins2 then check for dbc name
in $FND_TOP/secure.
If dbc file created with format alias_sid.dbc then change it to realname_sid.
dbc.
Example: Say alias name is dolphins2, real name is dolphins, sid is vis1159.
After running autoconfig, dbc file is created with the format alias_sid.dbc.
example; dolphins2__vis1159.dbc.
Rename that file to realname_sid.dbc. ex: dolphins__vis1159.dbc
Change dbc file name referenced in following files as well
jserv.properties, xmlsvcs.properties, zone.properties.
2. Once changes are made bounce apache using adapcctl.sh or adstrtal.sh. -
Hi guys,
How do I Display a string from a servlet into a JSP Page...
Ive tried so many bloody things!.....
Simply.
I get text from JSP. The servlet does what ever it does to the string.
Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
please help!!!hmmm, I dont really like using JSP programming, u should be using JAVA..
the way to do it is:
Call and cast to the bean like this:
<%@ page import="beans.*" %>
<% //cast to bean get request create object
userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
then... all you do is call it like this:
<input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
this is the real programmers way,,,
chet.~ -
Refreshing one frame only in a frame page
Hi all,
Pls help....i have this frame page with 4 frames. each one when click targets to another one on the same page...The last frame is a page which has 2 buttons Delete and Confirm and it has checkboxes.....when the checkbox are clicked and user clicks on Delete this specific frame page needs to be refresh and display the upated value....Right now it when i click on delete, it is being redirecting to blank window with the updated value and i need to click back to see the frame pages and the frame updated..which i do not want. Upon clicking Delete i want this specific frame to refresh and display the updated value....Pls help meeeeeeeeeeethanx a lot......geee....u have been of great help...i wrongly specified the target for my button in my javascript......
-
Servlets: Scrolling a html page
I have a servlet that generates a page with edit buttons,
rows, columns etc. When the edit button is pressed it
allows the current row to be edited (hence the name edit button ;). The problem is, when I press a button way down on the bottom of the page (scrollable) it works as it should (opens a html textfield(?) on the row) but the drawback is, that the page is hiked up and you have to scroll down and find the edit row. So is there a way I can scroll it down automatically near the edit row?
Thank youHave I understod correctly?
When you press the button the servlet generates a new page with the textfield.
You call the servlet something like this in the button: www.site.com/servlet/theServlet.
Then call it as www.site.com/servlet/theServlet#here and insert <a name="here"> before the textfield in the generated page (in the servlet code). -
Calling a servlet in a HTML page
hi evryone,
I'm new to servlets so i'm trying to create some simple applications to understand how it all works. The thing i'm trying to do is calling a servlet in a HTML page. I've already installed a Tomcat web server and I've created a servlet called Hello.
public class Hello extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String name = req.getParameter("name");
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>" );
out.println("<BODY>");
out.println("Hello, " + name);
out.println("</BODY></HTML>");
public String getServletInfo(){
return "testing servlet OK";
}In my HTML page I've written the follwing code:
<HTML>
<HEAD>
<TITLE>Just say hello</TITLE>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="../servlet/Hello">
What's your name?
<INPUT TYPE=TEXT NAME="name"><P>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>After running this HTML I get a text box and I thing I'm trying to do is, when I click on the button, the servlet will be loaded. However, the servlet can't be found and instead I get an error:
type Status report
message /servlet/Hello
description The requested resource (/servlet/Hello) is not available.
I suppose both file are in their approriate directories, but my class file still has the class extension. Do I need to change this? I hope that someone can help me.
Thanks in advance!hi,
the servlet wasn't in a package, so I changed that. It seems that I get an other error now:
HTTP Status 503 - Servlet servlet/Hello is currently unavailable
type Status report
message Servlet servlet/Hello is currently unavailable
description The requested service (Servlet servlet/Hello is currently unavailable) is not currently available.
I still don't know what I may have forgotten, so i'm gonna resume what i have done till now.
the servlet: (Hello.class)
package servlet;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Hello extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String name = req.getParameter("name");
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>" );
out.println("<BODY>");
out.println("Hello, " + name);
out.println("</BODY></HTML>");
public String getServletInfo(){
return "test servlet OK.";
}the HTML page (testServlet.html)
<HTML>
<HEAD>
<TITLE>Just say hello</TITLE>
</HEAD>
<BODY>
<FORM METHOD=GET ACTION="../servlet/Hello">
What's yoir name?
<INPUT TYPE=TEXT NAME="name"><P>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>the web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>servlet/Hello</servlet-name>
<servlet-class>servlet/Hello</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet/Hello</servlet-name>
<url-pattern>/servlet/Hello</url-pattern>
</servlet-mapping>
</web-app>paths of these files:
- Hello.class => D:\Tomcat 4.1\webapps\ROOT\servlet
- testServlet.html => D:\Tomcat 4.1\webapps\ROOT\more
( - web.xml => D:\Tomcat 4.1\webapps\ROOT\WEB-INF)
Thanks for your help!!! -
If I want have an embedded Forms Applet (Forms 9i Services) as part of an HTML Frames Page (for a typical web portal look), is it possible .
If possible , can anybody suggest the workaround.
Regards,
Gaurav SrivastavaIf use of Frames HTML Pages is possible with Forms 9i , where should be the <FRAME> tag inserted, in the base html files ? Or some separate arrangement should be done. Please do advice.
Regards,
Gaurav Srivastava -
How to access servlet objects from OA page controller class
Hi everybody!
I need to put some value into servlet attribute in OA page controller class to read it from ordinary servlet later.
How can i do it? Is it possible to get HttpServletRequest and HttpServletResponse objects from page controller?
Thank you.I have a servlet which receives uploaded files with special attributes (something like tags for file) using POST request.
This attributes created when user open page in standard OAF page via page controller.
On client side I have an applet which uploads user selected file to my servlet and passes this file attributes.
Now this attributes passes as plain text. I want to encrypt this attributes to hide attribute details from user. To do this I need to share some information between OAF page and my servlet.
I know that OAF supports URL encryption, but to decrypt it I should use standard pageContext object.
But in ordinary servlet I can't use it. -
I want to call a servlet in a frame:
<FRAME SRC="/servlets/My_Servlet" NAME="body" NORESIZE
frameborder="YES" scrolling="YES" bordercolor="#999999">
But I don't know if there is a way to pass in some parameter?
Thanks.<FRAME SRC="/servlets/My_Servlet" NAME="body"
NORESIZE
frameborder="YES" scrolling="YES"
bordercolor="#999999">
<frame src="/servlets/My_servlet?param1=val1¶m2=val2" name="body" frameborder="YES" scrolling="YES" bordercolor="#999999" noresize> -
Problem for getting the real path using one servlet and one jsp page
I have one tomcat machine and several virtual domains. Eahc virtual domain has one realpath in the disc.
I am using one servlet and one jsp page for using this servlet.
my purpose is to load, using the servlet , the real path for the domains (eahc domain has its path).
for this i make this:
the servlet code is this:
package utils.ticker;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.net.*;
import java.util.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class Edicion extends HttpServlet{
public Edicion() {
public String cc(){
ServletContext myContext= getServletContext();
String abspath = myContext.getRealPath("/");
//here i want to return the real path
return abspath;
public static void main(String args[]){
and the jsp page is:
<%@ page import="utils.ticker.*" %>
<jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
<html><head><body>
<%
tick.cc();
%>
</body></head></html>
But this produces one error, NullPointerException and dont shows me the real path.
Can anyone help me?
thanksi have put this into one sevlet:
package utils.ticker;
import javax.servlet.ServletContext;
public class Edicion{
private ServletContext myContext;
public Edicion(ServletContext myContext) {
this.myContext = myContext;
public String getCC(){
return myContext.getRealPath("/");
and in the jsp page this:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%@ page import="utils.ticker.*" %>
<jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
<html><head><body>
<%=tick.getCC()%>
</body></head></html>
but appear this error in the tomcat.
Can you, please, help me. i am trying to solve this during one week and i am desesperate.
Thanks.
ERROR:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
root cause
javax.servlet.ServletException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
at org.apache.jsp.pruebas_jsp._jspService(pruebas_jsp.java:72)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
Apache Tomcat/4.1.18 -
Call methods (which are in the servlet) in my response page
Hello !
I want to call methods which are in the servlet ( its name is ServletRecap) BUT the call is made in the response page which is generated by the servlet ServletRecap !
I just want to allow the user to update his choice in the response page.
example: i choice A in the initial form but i change my mind and now i want to choice B in the response page : the choice have to be update in the database.
the insertion in the DB is made by a method in the servlet : so i have to recall the method in the response page!
Please, anybody have an idea ?
my servlet :
public class ServletRecap extends HttpServlet {
// param�tres d'instance
private String urlErreurs = null;
private ArrayList erreursInitialisation = new ArrayList<String>();
private String[] param�tres = {"urlFormulaire", "urlReponse", "urlControleur", "lienRetourFormulaire"};
private Map params = new HashMap<String, String>();
// init
@SuppressWarnings("unchecked")
public void init() throws ServletException {
// on r�cup�re les param�tres d'initialisation de la servlet
ServletConfig config = getServletConfig();
// on traite les autres param�tres d'initialisation
String valeur = null;
for (int i = 0; i < param�tres.length; i++) {
// valeur du param�tre
valeur = config.getInitParameter(param�tres);
// param�tre pr�sent ?
if (valeur == null) {
// on note l'erreur
erreursInitialisation.add("Le param�tre [" + param�tres[i] + "] n'a pas �t� initialis�");
} else {
// on m�morise la valeur du param�tre
params.put(param�tres[i], valeur);
// l'url de la vue [erreurs] a un traitement particulier
urlErreurs = config.getInitParameter("urlErreurs");
if (urlErreurs == null) {
throw new ServletException(
"Le param�tre [urlErreurs] n'a pas �t� initialis�");
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// on v�rifie comment s'est pass�e l'initialisation de la servlet
if (erreursInitialisation.size() != 0) {
// on passe la main � la page d'erreurs
request.setAttribute("erreurs", erreursInitialisation);
request.setAttribute("lienRetourFormulaire", "");
getServletContext().getRequestDispatcher(urlErreurs).forward(
request, response);
// fin
return;
// on r�cup�re la m�thode d'envoi de la requ�te
String m�thode = request.getMethod().toLowerCase();
// on r�cup�re l'action � ex�cuter
String action = request.getParameter("action");
// action ?
if (action == null) {
action = "init";
// ex�cution action
if (m�thode.equals("get") && action.equals("init")) {
// d�marrage application
doInit(request, response);
return;
if (m�thode.equals("post") && action.equals("validationFormulaire")) {
// validation du formulaire de saisie
doValidationFormulaire(request, response);
return;
if (m�thode.equals("post") && action.equals("enregistrementFormulaire")) {
// enregistrement du formulaire de saisie
doEnregistrementFormulaire(request, response);
return;
if (m�thode.equals("post") && action.equals("retourFormulaire")) {
// retour au formulaire de saisie
doRetourFormulaire(request, response);
return;
// autres cas
doInit(request, response);
// validation du formulaire
void doValidationFormulaire(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// on r�cup�re les param�tres
String nomCentre = (String) request.getParameter("nomCentre");
String idCentre = (String) request.getParameter("idCentre");
String nomPreleveur = (String) request.getParameter("nomPreleveur");
String datePrelev = (String) request.getParameter("datePrelev");
String numFinFiche = (String) request.getParameter("numFinFiche");
// qu'on m�morise dans la session
HttpSession session = request.getSession(true);
session.setAttribute("nomCentre", nomCentre);
session.setAttribute("idCentre", idCentre);
session.setAttribute("nomPreleveur", nomPreleveur);
session.setAttribute("datePrelev", datePrelev);
session.setAttribute("numFinFiche", numFinFiche);
// v�rification des param�tres
ArrayList<String> erreursAppel = new ArrayList<String>();
// le nom doit �tre non vide
nomCentre = nomCentre.trim();
idCentre = idCentre.trim();
nomPreleveur = nomPreleveur.trim();
datePrelev = datePrelev.trim();
numFinFiche = numFinFiche.trim();
if (nomCentre.equals("")) {
erreursAppel.add("Le champ [nomCentre] n'a pas �t� rempli");
if (idCentre.equals("")) {
erreursAppel.add("Le champ [idCentre] n'a pas �t� rempli");
if (nomPreleveur.equals("")) {
erreursAppel.add("Le champ [nomPreleveur] n'a pas �t� rempli");
if (datePrelev.equals("")) {
erreursAppel.add("Le champ [datePrelev] n'a pas �t� rempli");
if (!numFinFiche.matches("^\\s*\\d+\\s*$")) {
erreursAppel.add("Le champ [numFinFiche] est erron�");
// des erreurs dans les param�tres ?
if (erreursAppel.size() != 0) {
// on envoie la page d'erreurs
request.setAttribute("erreurs", erreursAppel);
request.setAttribute("lienRetourFormulaire", (String) params.get("lienRetourFormulaire"));
getServletContext().getRequestDispatcher(urlErreurs).forward(
request, response);
return;
// les param�tres sont corrects - on envoie la page r�ponse
request.setAttribute("nomCentre",nomCentre);
request.setAttribute("idCentre",idCentre);
request.setAttribute("nomPreleveur",nomPreleveur);
request.setAttribute("datePrelev",datePrelev);
request.setAttribute("numFinFiche",numFinFiche);
request.setAttribute("lienRetourFormulaire", (String) params.get("lienRetourFormulaire"));
getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(request,
response);
return;
//enregistre dans la base de donn�e les variables
void doEnregistrementFormulaire(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String nomCentre = (String) request.getParameter("nomCentre");
String idCentre = (String) request.getParameter("idCentre");
String nomPreleveur = (String) request.getParameter("nomPreleveur");
String datePrelev = (String) request.getParameter("datePrelev");
String numFinFiche = (String) request.getParameter("numFinFiche");
String nEtude = datePrelev + "." + idCentre + "." + numFinFiche;
// qu'on m�morise dans la session
HttpSession session = request.getSession(true);
session.setAttribute("nomCentre", nomCentre);
session.setAttribute("idCentre", idCentre);
session.setAttribute("nomPreleveur", nomPreleveur);
session.setAttribute("datePrelev", datePrelev);
session.setAttribute("numFinFiche", numFinFiche);
Connexion com = new Connexion();
try{
//serveur,login,pwd,database
com.loadDriverAndConnect("127.0.0.1","3306","root","root","");
com.execute("USE BIOTECH");
com.execute("INSERT INTO RECAP (NEtude,NomCentre,idCentre,nomPreleveur,datePrelev) " +
"values ('"+nEtude+"','"+nomCentre+"','"+idCentre+"','"+nomPreleveur+"','"+ datePrelev + "')") ;
com.close();
catch(Exception ex) {
System.err.println("\n*** SQLException caught in main()");
request.setAttribute("urlAction", (String) params.get("urlControleur"));
getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(request,
response);
return;
// affichage formulaire pr�-rempli
void doRetourFormulaire(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
// on r�cup�re la session de l'utilisateur
HttpSession session = request.getSession(true);
// on pr�pare le mod�le du formulaire
// nom pr�sent dans la session ?
String nomCentre = (String) session.getAttribute("nomCentre");
if (nomCentre == null) {
session.setAttribute("nomCentre", "");
String idCentre = (String) session.getAttribute("idCentre");
if (idCentre == null) {
session.setAttribute("idCentre", "");
String nomPreleveur = (String) session.getAttribute("nomPreleveur");
if (nomPreleveur == null) {
session.setAttribute("nomPreleveur", "");
String datePrelev = (String) session.getAttribute("datePrelev");
if (datePrelev == null) {
session.setAttribute("datePrelev", "");
String numFinFiche = (String) session.getAttribute("numFinFiche");
if (numFinFiche == null) {
session.setAttribute("numFinFiche", "");
// urlAction
request.setAttribute("urlAction", (String) params.get("urlControleur"));
// on affiche le formulaire
getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
request, response);
return;
// post
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// on passe la main au GET
doGet(request, response);
my initial form:%
// on r�cup�re les param�tres dans la session
String nomCentre=(String)session.getAttribute("nomCentre");
String idCentre= (String)session.getAttribute("idCentre");
String nomPreleveur = (String)session.getAttribute("nomPreleveur");
String datePrelev=(String)session.getAttribute("datePrelev");
String numFinFiche=(String)session.getAttribute("numFinFiche");
String urlAction=(String)request.getAttribute("urlAction");
%>
<html>
<head>
<title>Fiche répitulative - formulaire</title>
</head>
<body>
<center>
<img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande" width="5%"></img>
<h2>Fiche répitulative - formulaire</h2>
<br>
<hr>
<form action="<%= urlAction %>" method="post">
[... page setting: made by html language ...]
<td><input type="submit" name="action" value="validationFormulaire"></td>
<td><input type="reset" value="Rétablir"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
my response page:<%
// on r�cup�re les donn�es
String nomCentre=(String)session.getAttribute("nomCentre");
String idCentre= (String)session.getAttribute("idCentre");
String nomPreleveur = (String)session.getAttribute("nomPreleveur");
String datePrelev=(String)session.getAttribute("datePrelev");
String numFinFiche=(String)session.getAttribute("numFinFiche");
String urlAction=(String)request.getAttribute("urlAction");
%>
<html>
<head>
<title>Fiche répitulative - formulaire</title>
</head>
<body>
<form action="<%= urlAction %>" method="post">
[... page setting: made by html language ...]
<br><br>
<td><input type="submit" name="action" value="enregistrementFormulaire"></td>
<td><input type="submit" name="action" value="retourFormulaire"></td>
</body>
</html>
my web.xml:<!-- Servlets -->
<!--Servlet Fiche Recapitulative-->
<servlet>
<servlet-name>FicheRecap</servlet-name>
<servlet-class>germande.ServletRecap</servlet-class>
<init-param>
<param-name>urlReponse</param-name>
<param-value>/WEB-INF/JSP/Recap/reponseRecap.biotech.jsp</param-value>
</init-param>
<init-param>
<param-name>urlErreurs</param-name>
<param-value>/erreursRecap.biotech.jsp</param-value>
</init-param>
<init-param>
<param-name>urlFormulaire</param-name>
<param-value>/WEB-INF/JSP/Recap/formulaireRecap.biotech.jsp</param-value>
</init-param>
<init-param>
<param-name>urlControleur</param-name>
<param-value>ServletRecap</param-value>
</init-param>
<init-param>
<param-name>lienRetourFormulaire</param-name>
<param-value>Retour au formulaire</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>FicheRecap</servlet-name>
<url-pattern>/ServletRecap</url-pattern>
</servlet-mapping>
</web-apps>
Thanks in advance for your idea.
I resume : how can I call a method in my servlet into my response page (in jsp).
the servlet generate this response page and i just want to update the choice of my user.
Thanks !!I resume : how can I call a method in my servlet into my response page (in jsp).Don't do that. Put the message into a plain old Java class which can be called from both the servlet and the JSP.
-
Can a servlet make a jsp page display?
A total newbie question. If I do this in a servlet:
RequestDispatcher rd = request.getRequestDispatcher( "/index.jsp" );
rd.forward( request, response );
- does index.jsp in the context path actually display?
If yes, what's wrong if it doesn't display?Yes, you can pass control from your servlet to the JSP page that way. If it isn't displaying, then you should show us the error message you are getting so that we can help you more effectively.
-
Servlet call from jsp pages on Hosting server instead of Local system
HI,
We have started hoste our projects on one of the Dedicated service from US.
We have used servlets in our projects and uploaded servlet based project on Dedicated server ,so now we are getting one ERROR ,when we try to access servlet pages from browser .
sample Below ERROR we are getting on browser ,when we try to access the servlet...
The requested URL /Globalcontactservlet was not found on this server
In Web.xml i have written mappings for servlets and i have included web.xml file under the Web-inf folder as same process we do on local system server.(Tomcat 5.5)
on browser i am trying to use the below format to request the servlet mapping
<form method="POST" action="http://www.xyz.com/Globalcontactservlet" >
</form>You can download Oracle's latest JDBC drivers from: http://otn.oracle.com/software/content.html
You need to register, but it should be free.
When you get the zip/jar-file, you have several options. You can either place it in the common classpath of your system/Servlet container (recommended if you use it in most of your webapps), or in the WEB-INF/lib directory of your webapp (if you only use it with that particular one).
.P. -
Error getting values by getParameterValues() in a servlet from a jsp page
Hi, i cant recive in my servlet the values that a user write in some input text in the next page:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="/ProyectoWeb/ServletPruebas" method="post">
<table>
<%
for(int i = 0; i<10; i++){
%>
<tr>
<td>
<input type="hidden" name="ps_oculto" value="<%=i%>">
<input type="text" name="ps_valor">
</td>
</tr>
<%
%>
</table>
<input type="submit" value="VALOR">
</form>
</body>
</html>and this is the post method of my servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw = response.getWriter();
String[] pocultos= request.getParameterValues("ps_oculto");
String[] valores= request.getParameterValues("ps_oculto");
for(String oculto: pocultos){
pw.println("ps_ocultos: " + oculto);
for(String valor: valores){
pw.println("ps_valores: " + valor);
pw.flush();
pw.close();
}When i open the jsp page in my web server and do the sumit of its form i get the folow response of my servlet:
ps_ocultos: 0
ps_ocultos: 1
ps_ocultos: 2
ps_ocultos: 3
ps_ocultos: 4
ps_ocultos: 5
ps_ocultos: 6
ps_ocultos: 7
ps_ocultos: 8
ps_ocultos: 9
valores: 0
valores: 1
valores: 2
valores: 3
valores: 4
valores: 5
valores: 6
valores: 7
valores: 8
valores: 9
I can´t get the values that i put in the input text when i open the jsp in my web server, (before press the submit button i write text in the input text), i only get indexes 0,1,2,3 ... What is wrong?
Thanks in advanceMy error its on the post method. I am getting the worg parameter for the values of my input text. I have change in the doPost the line
String[] valores= request.getParameterValues("ps_oculto");for this
String[] valores= request.getParameterValues("ps_valores");the code run perfect. Sometimes happens ... -
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
Maybe you are looking for
-
Mini-DVI DVI to DVI VGA adaptor issues
So, I just bought a snazzy new black MacBook, and am wanting to connect it to my old 20" NEC monitor, which uses VGA. Since I already have a DVIVGA cable that I used with my old tower (and I figure I'll someday upgrade to a DVI monitor), I thought it
-
Copying video from multiple itunes
I have 2 pc's with latest version of itunes. I have no problem copying music from either itunes to my touch. I purchased a copy of a movie from itunes and downloaded to one pc. Purchased a dvd copy of another movie that came with a digital copy that
-
Differences between xi 3.0 and pi 7.0
Hi friends, Can anybody please post the differences between XI 3.0 and PI 7.0? Thanks in advance.
-
Hi All after bapi calling we need to call commit my question is there any bapis with out transaction commit Regards Surendra
-
How do I delete an email contact?
I can't figure out how to delte an unwanted e-mail contact on my iMac e-mail. I don't want to just delete an e-mail but I want to remove the senders e-mail address intirely from my address book. Thanks