Servlet to Bean to JSP

I have a JSP that sends two form values to a servlet. I want to send those parameters to a bean for calculation and then send the results back to the JSP. I am stuck on the Servlet code and don't know how to send it back with the bean don't know how to start the bean:
import javax.servlet.*;
int rate, hours;
public class calculateParamServlet extends HttpServlet{
     public void doPost(HttpServletRequest req, HttpServletResponse res) throws
     ServletException, IOException {
          rate = req.getParameter("hourlyRate");
          hours = req.getParameter("hours");
}Any help would be appreciated,
Kent

A bean is just a Java class so the same rules apply.
e.g in the doPost method,
myBean mybean = new MyBean();
mybean.setRate(rate);
mybean.setHours(hours);
out.println(mybean.getCalc());
If you want to save the reference to the bean, save it in the application or session scope and check for its existence before creating it again. You could also do all this directly from the JSP.
HTH

Similar Messages

  • Hi frnds i want to help in servlet,java bean and JSP

    hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
    so pls give me a title about that
    NOTE: I develop a project in group(2 persons there)
    my email id is : [email protected] , [email protected] , [email protected]

    You cannot pair your iPod to a cell phone, so forget about it.
    The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve....

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • J2EE Java Beans and JSP

    I need a little help. I would like to learn jsp programming. Ive been browsing lots of tutorials on net but i didnt find any way how to use your own classes in jsp. I suppose it could do something with Java Beans but im new them so i dont know. Lets say ive got a login form with a username and password. After i send it to another jsp lets say verify.jsp i would like to verify the user using a class ive got. It goes through a xml file with some accounts and looks for the desired user if the password is correct. Now how do i call a method: boolean verifyUser( String user, String password) in the verify.jsp file? Is it possible?
    Thanks for help

    you'll probably want to have a central servlet that all your JSPs will talk to and acts as a traffic cop to direct navigation between pages. it can be the one to add JavaBeans as attributes to page/request/session/application scope. Your JSP can then get the Bean as an atribute and call its isValid method.
    Java Beans are NOT Enterprise Java Beans. Be sure you understand the difference. The former are Java objects that follow Bean conventions; the latter are Java objects that extend EJB types and run in a container. Very different.
    %

  • Using java bean with jsp

    hello friends,
    i'm new to jsp. i want to create an html form that accepts username and a value from four radio buttons and display back the entered name and checked radio button's value using java bean.
    i use the <jsp:setProperty id="" property="*"> method. i don't know how to access the radio buttons value from the html.
    also when i use an additional field other than username the jsp page is showing error.
    Please give me the correct method to use java bean with jsp in this circumstance.
    thank you.

    thank you, but i have a problem left. the case is like this.
    i got the jsp and bean worked fine when i have a sinle input text field.
    but when i added a second text field i recieved the following error.
    javax.servlet.ServletException: basket.newbean.getUserPass()Ljava/lang/String;
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
         org.apache.jsp.newform.process_jsp._jspService(process_jsp.java:69)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    where userPass is the new form element. I have made the subsequent chanes in my bean program and jsp file.
    pls hlp.

  • Calling Beans from JSP page

    hi,
    I tried to my best to call java beans from JSP page but it generate error that "unable to load class....", please help me that in which directory jsp file and bean *.class file reside, currently my setting are as follows.
    Note: I am using tomcat server and my jsp and servlet files are running seccessfuly, there is any special change in classpath for java beans? if any please tell
    My jsp file is in tomcat-->webapps-->jsp--><my file>
    My bean (*.class) file-->webapps-->Root-->web-inf-->classes--><my file>
    Pleae help me for the above problem.
    Mubashar ([email protected])

    According to J2EE standards:
    The web appl directory structure should be:
    WebAppRootDirectory
    |
    |---html, jsp, images etc
    |
    |---WEB-INF---
    |---classes--
    |---lib
    |
    |
    1) Make sure WEB-INF is in capital letters
    2) Place all ur beans in classes dir or sub-directory in
    classes
    3) In Tomcat place WebAppRootDirectory in webapps
    directory
    [email protected]

  • How to call java bean from jsp

    hi
    How to call a java bean from jsp page..
    Is any other way to call javabean from jsp page apart from this sample code...
    <jsp:useBean id="obj" class="com.devsphere.articles.calltag.TestBean"/>
    thnx in advance

    If you also use servlets, you can attach beans to the request or session and use them directly in your JSP's. So if you do:
    request.setAttribute("name", yourBean);and then forward to a JSP, you can reference the bean like:
    ${requestScope.name}

  • Calling bean using jsp

    i've installed tomcat v3.3.2, and set the environment variable as normal procedure has mentioned..i have j2sdk 1.4.2_08, and recently has try to expirment calling java beans using jsp file located at D:\jakarta-tomcat-3.3.2\webapps\helloworld.jsp, and my bean file is located at D:\jakarta-tomcat-3.3.2\webapps\ROOT\WEB-INF\classes\com\bean\test\hellobean.class, and my hellobean.java source is :
    package com.bean.test;
    public class hellobean implements java.io.Serializable
    private String Name;
    public hellobean() {}
    public String getName()
    {return Name;}
    public void setName(String Name)
    {this.Name=Name;}
    and my jsp file source:
    <html>
    <body>
    <jsp:useBean id="hello" class="hellobean">
    <jsp:setProperty name="hello" property="Name" value="Alan"/>
    </jsp:useBean>
    <h1>hello, <jsp:getProperty name="hello" property="Name"/></h1>
    </body>
    </html>
    and when i run start.bat and type http://localhost:8080/helloworld.jsp, it gave me this error:
    Error: 500
    Location: /helloworld.jsp
    Internal Servlet Error:
    org.apache.jasper.JasperException: hellobean
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:140)
         at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:59)
         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:747)
         at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:176)
         at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:131)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:169)
         at org.apache.tomcat.facade.JasperLiaison.jsp2java(JspInterceptor.java:765)
         at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:706)
         at org.apache.tomcat.facade.JspInterceptor.preInitCheck(JspInterceptor.java:493)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:413)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:874)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:790)
         at org.apache.coyote.tomcat3.Tomcat3Adapter.service(Tomcat3Adapter.java:64)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
         at java.lang.Thread.run(Thread.java:534)
    Root cause:
    java.lang.ClassNotFoundException: hellobean
         at org.apache.tomcat.util.depend.DependClassLoader12Impl.loadClassInternal1(DependClassLoader12.java:205)
         at org.apache.tomcat.util.depend.DependClassLoader12Impl$1.run(DependClassLoader12.java:78)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.tomcat.util.depend.DependClassLoader12Impl.loadClass(DependClassLoader12.java:76)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:138)
         at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:59)
         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:747)
         at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:176)
         at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:131)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:169)
         at org.apache.tomcat.facade.JasperLiaison.jsp2java(JspInterceptor.java:765)
         at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:706)
         at org.apache.tomcat.facade.JspInterceptor.preInitCheck(JspInterceptor.java:493)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:413)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:874)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:790)
         at org.apache.coyote.tomcat3.Tomcat3Adapter.service(Tomcat3Adapter.java:64)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
         at java.lang.Thread.run(Thread.java:534)
    can anybody help me? thanks

    Hi
    Same problem as above and did everything as posted here in the page, but still doesn't solve my problem.
    Here's the bean :
    package com.partha;
    public class CounterBean
    private int counter=0;
    public int getCounter()
    return counter;
    public void incrementCounter()
    counter++;
    Here's the JSP Page :
    <%@ page language="java" %>
    <jsp:useBean id="session_counter" class="com.partha.CounterBean" scope="session"/>
    <jsp:useBean id="application_counter" class="com.partha.CounterBean" scope="application" />
    <html>
         <head>
              <title>Exercise 3</title>
         </head>
         <body>
              <%= session_counter.incrementCounter() %>
              <%= application_counter.incrementCounter()%>
              The number of times this session was accessed :
              <jsp:getProperty name="session_counter" property="counter" />
              <br>
              The number of times this page was accessed :
              <jsp:getProperty name="application_counter" property="counter" />
         </body>
    </html>
    I am still getting a classnot found exception . Here's what I am getting :
    java.lang.ClassNotFoundException: com.partha.FormBean
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1407)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1252)
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:133)
         at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:650)
         at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:507)
         at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
         at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
    Please help me out ..

  • What is the difference between java direct or java bean in JSP?

    What is the difference if I use java code directly in JSP or use java bean in JSP?
    Which class to use for receiving the passed parameter from html or java script? Any difference for java code and java bean in the way receiving the passed data?
    How can I pass string from jsp to html or java script?

    it's generally accepted as better design to separate presentation from logic. meaning, the java code in the jsp should be used to support displaying data, as oppsoed to implementing the application - like database access, etc.
    when the logic is separated from the presentation, it allows you to reuse logic components within several jsp pages.
    if you decide to change the presentation layer in the future (to support wap, for example) you don't need to rewrite your entire application, since the "guts" of the application is outside of the jsps.
    it is also a good idea to separate your business logic from your data layer. adding a "buffer zone" between these layers helps in the same manner as in separating presentation from logic. if you're using flat files for storage now, upgrading to a database wouldn't require rewriting all your business logic, just the methods which write out the data to a file, for example.
    once you feel comfortable with separating the various layers, check out the struts framework at http://jakarta.apache.org/
    to answer your second question, to get parameters passed in from HTML forms, use ServletRequet's getParameter() method.
    in tomcat:
    <% String lastName = request.getParameter( "lastname" ); %>
    to answer your third question: when displaying the HTML from withing a jsp, print out the string to a javascript variable or a hidden form element:
    <% String firstName = "mike"; %>
    <input type="hidden" name="firstname" value="<%= firstName %>">
    <script language="javascript1.2">
    var firstName = "<%= firstName %>";
    </script>
    this jsp results in the following html:
    <input type="hidden" name="firstname" value="mike">
    <script language="javascript1.2">
    var firstName = "mike";
    </script>

  • Problem with java beans and jsp on web logic 6.0 sp1

              HI ,
              I am using weblogic6.0 sp1.
              i have problem with jsp and java beans.
              i am using very simple java bean which stores name and email
              from a html form.
              but i am getting following errors:
              Full compiler error(s):
              D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              cannot resolve symbol
              symbol : class userbn
              location: class jsp_servlet._savename2
              userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              ^
              D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              cannot resolve symbol
              symbol : class userbn
              location: class jsp_servlet._savename2
              userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              ^
              D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:94:
              cannot resolve symbol
              symbol : class userbn
              location: class jsp_servlet._savename2
              ud = (userbn) java.beans.Beans.instantiate(getClass().getClassLoader(),
              "userbn"); //[ /SaveName2.jsp; Line: 7]
              ^
              3 errors
              in which directory should i place java bean source file(.java file)
              here is my jsp file:
              <%@ page language = "java" contentType = "text/html" %>
              <html>
              <head>
              <title>bean2</title>
              </head>
              <body>
              <jsp:usebean id = "ud" class = "userbn" >
              <jsp:setProperty name = "ud" property = "*" />
              </jsp:usebean>
              <ul>
              <li> name: <jsp:getProperty name = "ud" property = "name" />
              <li> email : <jsp:getProperty name = "ud" property = "email" />
              </ul>
              </body>
              <html>
              here is my bean :
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              import java.io.*;
              public class userbn implements Serializable
                   private String name ;
                   private String email;
                   public void setName(String n)
                        name = n;
                   public void setEmail(String e)
                        email = e;
                   public String getName()
                        return name;
                   public String getEmail()
                        return email;
                   public userbn(){}
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              pls help me.
              Thanks
              sravana.
              

              You realy can do it like Xiang says, but the better way is to use packages. That's
              the way BEA is designed for. If you use packages you can but your bean classes
              in every subfolder beneath Classes. Here for example we have the subfolders test
              and beans:
              You have to declare the package on top of your Bean Source Code:
              package test.beans;
              In your JSP you don't need the import code of Xiang. You only have to refer the
              path of your bean class:
              <jsp:useBean id="testBean" scope="session" class="test.beans.TestBean" />
              There are some other AppServers that only can deploy Java Beans in packages. So
              if you use packages you are always on the right side.
              ciao bernd
              "sravana" <[email protected]> wrote:
              >
              >Thank you very much Xiang Rao, It worked fine.
              >Thanks again
              >sravana.
              >
              >"Xiang Rao" <[email protected]> wrote:
              >>
              >><%@ page import="userbn" language = "java" contentType = "text/html"
              >>%> should
              >>work for you.
              >>
              >>
              >>"sravana" <[email protected]> wrote:
              >>>
              >>>HI ,
              >>>
              >>>I am using weblogic6.0 sp1.
              >>>
              >>>i have problem with jsp and java beans.
              >>>
              >>>i am using very simple java bean which stores name and email
              >>>
              >>>from a html form.
              >>>
              >>>but i am getting following errors:
              >>>
              >>>________________________________________________________________
              >>>
              >>>Full compiler error(s):
              >>>D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              >>>cannot resolve symbol
              >>>symbol : class userbn
              >>>location: class jsp_servlet._savename2
              >>> userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              >>> ^
              >>>D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              >>>cannot resolve symbol
              >>>symbol : class userbn
              >>>location: class jsp_servlet._savename2
              >>> userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              >>> ^
              >>>D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:94:
              >>>cannot resolve symbol
              >>>symbol : class userbn
              >>>location: class jsp_servlet._savename2
              >>> ud = (userbn) java.beans.Beans.instantiate(getClass().getClassLoader(),
              >>>"userbn"); //[ /SaveName2.jsp; Line: 7]
              >>> ^
              >>>3 errors
              >>>
              >>>____________________________________________________________
              >>>
              >>>in which directory should i place java bean source file(.java file)
              >>>
              >>>here is my jsp file:
              >>>--------------------------------------------------------
              >>>
              >>><%@ page language = "java" contentType = "text/html" %>
              >>><html>
              >>><head>
              >>><title>bean2</title>
              >>></head>
              >>><body>
              >>><jsp:usebean id = "ud" class = "userbn" >
              >>><jsp:setProperty name = "ud" property = "*" />
              >>></jsp:usebean>
              >>><ul>
              >>><li> name: <jsp:getProperty name = "ud" property = "name" />
              >>><li> email : <jsp:getProperty name = "ud" property = "email" />
              >>></ul>
              >>></body>
              >>><html>
              >>>
              >>>-------------------------------------------------------------
              >>>
              >>>here is my bean :
              >>>
              >>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              >>>
              >>>import java.io.*;
              >>>
              >>>public class userbn implements Serializable
              >>>{
              >>>
              >>>     private String name ;
              >>>
              >>>     private String email;
              >>>
              >>>     public void setName(String n)
              >>>     {
              >>>
              >>>          name = n;
              >>>     }
              >>>
              >>>     public void setEmail(String e)
              >>>     {
              >>>
              >>>          email = e;
              >>>     }
              >>>
              >>>     public String getName()
              >>>     {
              >>>
              >>>          return name;
              >>>     }
              >>>
              >>>     public String getEmail()
              >>>     {
              >>>
              >>>          return email;
              >>>     }
              >>>
              >>>     public userbn(){}
              >>>}
              >>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              >>>
              >>>pls help me.
              >>>Thanks
              >>>sravana.
              >>>
              >>
              >
              

  • How to call a jsp file from an servlet and access the jsp file objects??

    Hi everybody
    I have an jsp file where it contains a vector object with some data and I have a servlet that needs to access this vector object . How can my servlet call for this jsp page and get the vector object. ?
    then an applet will be calling this servlet to get some other object created with the data contained within this vector object...so each time Applet ask the servlet for the object the servlet need to call for this jsp page somehow
    My main question is the communication servlet-jsp
    please if u have any clue I will appreciate it
    thanks

    Hi
    There are several ways to share objects between JSPs/Servlets.
    You can share objects by putting them in the request-in which case the objects lifetime is limited by that of the request, Another way is to store them in the session, againg the lifetime is limited by the lifetime of the session. To have objects that have to persistent over the application life-span use the servletContext to store the objects.
    Any good tutorial should help you get started. Please see the link below for a tutorial on Servlets/JSPs
    Note: Local variables in the JSP cannot be shared with other components as their scope is limited to that particular Page/Servlet.
    Link: http://java.sun.com/docs/books/tutorial/servlets/
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • How to debug a bean in JSP page with JBX???

    How to debug a bean in JSP page with JBX???
    i have a bean within a JSP page. i wanna find out how do they varibles work and changes of them values.
    are there some ways or tools to get the situations of them in visual way? just like when i debug VB program,i can get the situations in immediately window.

    help me !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Beans through jsp

    hi,
    i' m trainee developer and working in struts. i'm totally novice in this regard. my pl asked me to develop an application on struts. i'm getting problem while using bean through jsp. i'm writing code:
    <jsp:useBean id="myBean" class="MyBean" type="MyBean" scope = "session"/>
    the error is:
    cannot resolve symbol
    symbol : class MyBean
    location: class org.apache.jsp.confirm_jsp
    MyBean myBean = null;
    ^
    total 3 errors associated with it. MyBean class is located in WEB-INF/classes
    can any one help me out?

    put your bean in a package and put that package under the WEB-INF/classes directory. Then use the fully qualified class name for the jsp:useBean:
    //in the bean
    package net.thelukes.myprog.beans;
    //the jsp:useBean
    <jsp:useBean id="myBean" class="net.thelukes.myprog.beans.MyBean" scope="session"/>

  • Can a single servlet process 2 diffrent jsp pages?

    I am kinda new to the jsp world. Here is the question i have.
    I have 2 jsp pages and a sigle servlet class. Both the jsp pages need to be processed by the same servlet. The servlet needs to run diffrent logics based on which jsp the request is being sent from. Is there any way for the servlet to know which jsp the request is coming from( like having an attribute in the form tag of the jsp which the servlet can later retrieve)?
    I am using only jsp's and servlet( not using any other technology like struts or JSf's). I appreciate any kind of help. Thank you.

    Yes, you can! It depends on how you access the servlet. If you access it via GET method you must add a request parameter to the url to distinguish from which jsp the request comes. If you use POST method (with form submission) put a hidden field in the form and with that field you can recognize from which jsp the request comes.
    Message was edited by:
    amittev

  • How can i use JAVA BEAN and JSP?

    well, i have developed all my web apps by using pure JSP only, i know this sucks, but i dont know how to start on using beans... what directory should i put them into... etc... what are the good programminmg practices/standards/techniques when incorporating beans in jsp???

    Standards are pretty loose, but generally, Beans hold a lot of the backend logic for your JSP. This can include data validation before entering into the database, database inserts, queries, data manipulation. The JSP should really only contain code that will retrieve the data from the bean and appropriately output it.
    As far as using them, you can use the <jsp:useBean> tag in your JSP. As long as the bean is stored somewhere that your classpath points to, you're all set. From then on, you can use it like any other object in your JSP.

Maybe you are looking for

  • Writing and including our own customer data source to Crystal Report Design

    Hi, I need to create a Crystal Report based on a locally stored XML and schema. I can do this but the issue Iu2019m facing is that some tags used in the schema and the format is not supported by Crystal. So my plan is to write a database driver which

  • X99S Gaming 7 won't get past BIOS Splash sometimes

    Have the system pretty vanilla, booting as UEFI only and I'm seeing from a cold boot that it gets to the BIOS screen (press F11 or Del) then just sits there. Any idea(s) what to check?

  • Qosmio F30-117: How Vista calculate Win Experience Index Graphics score?

    My F30-117 has a Display adapter type NVIDIA GeForce Go 7600. WIE gives this a graphics score of *4.9* based on the following info: Total available graphics memory 399 MB Dedicated graphics memory 128 MB Dedicated system memory 0 MB Shared system mem

  • Upgradation Steps from OBIEE 11.1.1.3 to 11.1.1.6

    Hi friends, Im following the below link for upgrading my obiee 11.1.1.3 to 11.1.1.5 http://docs.oracle.com/cd/E23943_01/bi.1111/e16452/bi_plan.htm#BABECJJH In that they asked to follow the following 11 steps to accomplish, and those are "Perform Gene

  • So confused!!

    I need to install Windows on my mac so that I can download a mortgage program that I use. I am nervous about installing windows because of virus' & I dont want it to slow my mac down. Will either of these things happen? I am a first time mac owner. I