Jsp starting a servlet?

Hiho!
Someone know a way to start a servlet thru jsp as soon as the jsp starts? no buttons or nothing just starting the servlet as the jsppage is finished loading..

Well.. I am a noob at jsp and servlets.. No matter how old I am Im still a beginner at it.. And I asked for help since I need it.. The one acting like a child would be you who act "cool"? If you think it's simple then just help me out with what to do instead of acting big?
And earning respect? Im supposed to earn respect to ask a question on a forum? Cause I can't ask the question in a certain way?
If you don't want to answer the question cause I haven't earned your "respect" then don't.. But what's the reason to be such a prick bout it?

Similar Messages

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • Executing a jsp from a servlet

    Hello all
    I am a starter to JSP.
    In an application I am developing, I have a servlet which receives a request from a form. If the user asks for a tabular representation of data (from the database), I want to use a JSP to display such a table since that way, I do not have to write all those out.printlns used in a servlet.
    So is there a way to either pass control to a jsp from a servlet? I want to pass a hashtable and some data to the jsp from the servlet.
    Please help with possible suggestions and code.
    thanks a lot....
    Mahesh :)

    There is the RequestDispatcher object to forward request to another resource (as servlet or jsp).
    If in your servlet you code:
    RequestDispatcher rd=getServletContext().getRequestDispatcher("your JSP URL");//instantiate a RequestDispatcher object
    //sets Hastable as request attribute
    request.setAttribute("yourAttributeName",yourHashtableName);
    rd.forward(request,response);//forwards control to jsp
    In your JSP you will retrieve Hashtable by following code:
    Hastable ht=(Hashtable)request.getAttribute("yourAttributeName");

  • Retrieve values from a table of a JSP page in Servlet.

    Hello all,
    I am new in JSP servlet world, I want to create a grid on JSP page using Servlet.
    Suppose i have some records in a JSP page and This JSP page will display these records in a tabular form. And, on a button click that table data should be
    accessible in servlet,
    Now, How can i traverse among all the rows of that table of JSP page in servlet. or How can i retrieve a specific cell record of that table of JSP page in servlet.
    Can anyone please answer this.
    Thank you and regards.

    Hi,
    Create in your HTML form inputs with the same name i.e.:
    <input name="a[]" value="2" >
    <input name="a[]" value="9" >
    In your jsp page use :
    String Values[] = request.getParameterValues("a[]") ;
    This will give you a string array of two elements.
    for (int x = 0; x < Values.length; x++)
        System.out.println(Values[x]) ;
    }Will print :
    2
    9
    Hope this helps.
    Bill Moo

  • 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 Adnan

    You need to elaborate "not working" in developer's perspective instead of in user's perspective.

  • How to start a Servlet on the Startup of my application

              Hai al,
              I have an requirtment abt an application on which i need to start a servlet
              when my application starts. i am blank abt how to do this. can any body help me
              to do ths. Please mention the steps involved in doing this.
              Cheers
              Senthil Kumar M Rangaswamy
              

    In web.xml deployment descriptor, specify <servlet><load-on-startup>1</load-on-startup></servlet>
    element.
    thanks,
    Deepak
    "Senthil Kumar M Rangaswamy" <[email protected]> wrote:
    >
    Hai all,
    I have a requirment in my application, that i need to start a servlet
    (automatically)
    when i start my application, am blank in how to do ths can any body help
    me to
    achive ths. waitiing for a ur replys.
    cheers
    Senthil kumar MR

  • Accessing String assigned in a JSP from a Servlet?

    Hello all, I was wondering if there is a way to access a String object that was assigned by an HttpSession object in a JSP from a Servlet. What happens is, in my application a user logs in, an HttpSession object is instantiated and all of the user credentials are assigned within a JSP like:
    HttpSession httpSession = request.getSession( false );
    String userName = httpSession.getAttribute("userName);
    ...{code}
    Next, I have a Servlet (which is really just a Proxy to a different server), that I need to log some information with, namely the userName String. Is there a way I can access that String without instantiating another HttpSession object? Because when the timeout occurs (or when the user clears his cache I have found), the HttpSession becomes invalidated (even if I use  +HttpSession#getSession( true )+) and the +HttpSession#getAttribute+ call fails (userName is just null). So is this possible to do?
    Thanks in advance!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    dnbphysicist wrote:
    I understand you cannot recover attributes from a dead session, this is why I wanted to be able to access a variable that is pulled from the Session immediately after login so I can still get to it even once the session is dead.
    Normally a session doesn't go dead after login.
    I imagine that by using application scope the app would confuse the userName with other users that are logged in?Certainly. It was just an example. But your data clearly belongs in the session, so just keep it in the session. If the session get invalidated while it should not get invalidated, then your problem truly lies somewhere else.
    I am definitely not arguing you latter point either :) A lot of this code I inherited unfortunately from previous developers and we are in desperate need of a redesign.I wish you much luck with that.

  • How to pass a object of JSP to a servlet called from JSP

    Hi,
    I am trying to display an image in the JSP through html image tag. I am using Struts Action class to get the image data from the database through a Session EJB. I am getting a byte array for the image retrieved from the database.
    To display the image I need to call a servlet from the JSP from the image tag like this.
    <html:img src="imageservlet" border="0"/>
    But I need to send the image byte [] array data which is available with the JSP to the servlet to build image. I have a bean object with the JSP which holds the image byte []. The servlet should receive the bean object and will use the byte [] and build the image to be displayed.
    My query here is how to send this bean object to the servlet which is getting called from the JSP as shown above.
    Thanks in advance.

    Hi,
    Thanks for your response. I knew it is possible with session objects. But I want to perform this operation with out using session objects. Is there a way to accomplish this with out using Session objects.
    Please help.
    Thanks

  • If there is a problem starting a servlet....

    I'm currently writting an exception handler for my servlet's init() method.
    My question is, if there is a problem initialising the servlet (i.e. config files won't load etc) what's the best way to put the servlet out of action?
    I'm thinking maybe call the destroy() method within the catch block of init(). Would this be right?
    If so what happens if the servlet is shutdown and then there is another request? Will the container (Tomcat) attempt to start the servlet again?
    Thanks,

    When you say "And the container will always attempt to
    start the servlet after startup." Do you mean after
    shutdown?That's a strange way to say it, but I suppose you might look at it that way. The container shuts down at some point in time. It doesn't attempt to init the servlet then, but after it starts up it does attempt to init the servlet. Either immediately or upon its first use.
    It seems a bit strange for the container to keep
    restarting a servlet that will always fail on init().How should the container know that? It cannot make any assumptions about what init() might do the next time. Perhaps it failed because the system manager put a configuration file in the wrong place; it might be there now. Basically it's the manager's problem if the servlet init() fails every time, not the container's.
    Oh and I don't suppose there is a class constuctor
    exception is there, for when a constructor fails?Constructors can throw exceptions if they are designed to do so.

  • Generating the JSP from the Servlet source file

    Hi,
    Does anyone out there know if there is any utility/class/program which will generate a JSP from the Servlet Source file (.java file) or indeed from the compiled Servlet file (.class file)
    If its possible to decompile a .class file into a .java file, surely it must be possible to convert the .java souce file into the .jsp file that created it.
    any comments would be appreciated
    Richard

    I am the author of the original JSP!
    But I want to run a script on the generated Servlet source file,
    changing its contents, and then generate the JSP that would have created the new Servlet source file.
    but I need to know if theres anything that will reverse engineer a Servlet source into the generating JSP.
    its a kind of of Jeopardy type thing!

  • JSP refresh from servlet.

    Hi everyone
    I'm creating a web application that is a combination of jsp pages and servlets.
    On one of the jsp pages I add contact details of a person in a form, then when submitted it goes to the servlet which adds the new contact into the database,
    after the servlet entered the data it redirects to the ContactList.jsp page, but it doesn't show the newly created user, I need to refresh the page manually to see the users.
    How can I from the servlet when I redirect to the ContactList.jsp page, refresh the ContactList.jsp page to show the newly created contacts well?
    Here is the servlet which gets called when I submit the jsp form.
    package contacts;
    import javax.servlet.*;*
    *import javax.servlet.http.*;
    import java.io.*;*
    *import contacts.*;
    public class NewContactServlet extends HttpServlet
         public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              res.setHeader("Expires", "Tues, 01 Jan 1980 00:00:00 GMT"); //no cache allowed
              Contacts contacts = new Contacts();
              ContactsData contactsData = new ContactsData();
              contacts.setContactName(req.getParameter("contactName"));
              contacts.setCompany(req.getParameter("companyName"));
              contacts.setWorkNumber(req.getParameter("workNum"));
              contacts.setCellNumber(req.getParameter("cellNum"));
              contacts.setFaxNumber(req.getParameter("faxNum"));
              contacts.setEmail(req.getParameter("email"));
              contacts.setCountry(req.getParameter("country"));
              contactsData.addContact(contacts);
              res.sendRedirect("ContactList.jsp");
    }

    Hi manuel.leiria
    Here is my code for refreshing the jsp, it is working.
    Just tell me what you think, if it's the right way.
    The servlet that sets the attribute
              session.setAttribute("contactsSession","add");
              res.sendRedirect("ContactList.jsp");The jsp page that gets the page.
              <%
              String refreshSession = (String)session.getAttribute("contactsSession");
              if(refreshSession != null && refreshSession.equals("add"))
                   %>
                   <body onload="window.location.reload(true);">
                   <%
                   session.removeAttribute("contactsSession");
              else
                   %>
                   <body>
                   <%
              %>

  • JSP, Bean, or Servlet?

    I've found that alot of the time, the systems I'm trying to design can use all of these to accomplish the same task. What's a good indicator of whether or not I should be using one technology over another?
    For example, most recently, I designed an html form that is used to create registration html forms for clients. I can send the data in my form to another jsp page, a servlet, or a bean. ALL THREE can accept the date and use BufferedWriter to create and write to the registration form. Why would I want to use one over the other?
    Any help here would be greatly appreciated. I am seriously lacking in proper system design knowledge.

    If you want to use the data all through the user session, posting data to a JSP or a Servlet may require either URL rewriting or using hidden elements to preserve the state.
    Its a better idea to store the data in a ValueObject (a simple java bean with get and set for all the properties).
    You may want to refer to J2EE Patterns to find out more about the patterns you can use to design good server side application.

  • Why we should use JSP instead of Servlet ?

    I want to know what are the advantages to use JSP over Servlet.

    hi
    Servlets are server exctension ( like CGI ) separate executable
    modules to serve any request efficiently.
    Servlets are pure java classes, u can use them the write an html code to browser.
    u have to compile the servlet before u use it.
    JSP page, is a text-base document , u can type html inside it , and u can use java as scripting language, so it is more easy to use jsp rather than servlet as each jsp page is translated into a servlet by JSP engine.
    Hope this will help
    Good luck
    Mohammed

  • R separate personalization classes reqd 4  jsps managed by servlet portlet?

    My portlet is a servlet which manages multiple jsps. This servlet manages the session data as well as navigation between the pages. At the moment, I have separate personalization classes for each of the jsps. Each personalization class extends NameValuePersonalizationObject. The content on each of the jsps has to be managed within the portal.
    Do I need to have separate personalization classses or is it better to have one personalization class for all the jsps within my portlet ?
    Any help would be great, Thanks,
    Tara

    Hi,
    After going through your application scenario, i think you should use just one Personalization Class. A single class would suffice all the four JSPs.
    But, as you might be aware, a Preference Store can only store basic data types like String, boolean etc. Complex Data Types like Properties etc. cannot be stored directly using NameValuePersonalizationObject. If you are storing complex types, then you will have to extend this class & define methods to store & fetch data from this complex object into the Personalization Store.
    You might want to go through the following article which talks about Information Storage using Web Providers.
    http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/PDK/articles/overview.information.storage.html
    If there are any further issues, please get back.
    Regards,
    Abhinav

  • Why is a JSP page or servlet (SingleThreadModel) unreachable on iPlanet 6.0 webserver after client abort?

    After client abort (user pushes STOP on the browser, etc.) JSP page or servlet (SingleThreadModel) is unreachable on iPlanet 6.0 webserver. Only a server restart helps. Can anybody help me?

    adsfadsfaf

Maybe you are looking for

  • Where can i get an apps to install photoshop 5.5 on windows 8

    anyone know where to get this apps thanks

  • Using Mac Mini on 220v line

    I just purchased a Mac mini and will use it overseas. Can I just put a plug adapter on and plug into 220v?

  • Requirement Reduction integration model

    Hi, Can someone explain in layman terms with an example what happens when "requirment reduction" object is CIF'd alongwith Planned independent Requirements (to APO). Why should/would someone create an integration model for requirement reduction when

  • "Clean install" on PowerMac G5?

    How do you execute a "Clean Install" on a PowerMac G5. I am currently running Mac OS 10.5.8. And I have Mac OS X Leopard Install CD (not Snow Leopard). The reason I need to do this is that my OS is acting very quirky. For instance, I need to force qu

  • Can't configure WRT160N

    Hello All I have a WRT160N that I used just once after purchase (my ISP gave me a wireless router). I could not remember the PW, so I reset. (The computer saw the old router name but I had no PW) When I run the software (CD that came with the product