Session Rules from Servlet to JSP

I'm getting a null pointer exception from the else statement in the JSP below when I check to see if a user has been authenticated by a servlet.
Are there any problems with the else statement to cause an exception?
<% /**Verify Authenticationt*/
HttpSession mysession = request.getSession();
String loginUrl = "/hr/servlet/SessionLoginServlet";
if (mysession==null)
response.sendRedirect(loginUrl);
else {  //below code causing null pointer exception
String loggedIn = (String) mysession.getAttribute("loggedIn");
if (!loggedIn.equals("true"))
response.sendRedirect(loginUrl);
%>
The Servlet's doPost:
public void doPost(HttpServletRequest request, HttpServletResponse
response)throws ServletException, IOException {
String userName = request.getParameter("userName");
String password = request.getParameter("password");
if (login(userName, password, response)) {
//send cookie to the browser
HttpSession session = request.getSession(true);
session.setAttribute("loggedIn", new String("true"));
response.sendRedirect("/hr/jsp/PAStart.jsp");
else {
sendLoginForm(response, true);
}

Unfortunately, no. You'll need to say:
if (loggedIn != null || !loggedIn.equals("true"))
It's how the equals() works for String objects. You need two objects to check equality.

Similar Messages

  • How do I lookup an EJB 3.0 Session bean from servlet or JSP?

    Does anyone knows how can I invoke an EJB from a servlet or JSP ?
    I deployed a simple EJB on a Oracle Application Server 10g release 10.1.3 and I'm working with JDeveloper 10.1.3. I deployed the files via JDeveloper, and I didn´t specify any orion-ejb-jar.xml or ejb-jar.xml file
    After deployment, the orion-ejb-jar.xml look like this in the server:
    <?xml version="1.0" encoding="utf-8"?>
    <orion-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-ejb-jar-10_0.xsd" deployment-version="10.1.3.0.0" deployment-time="10b49516c8f" schema-major-version="10" schema-minor-version="0" >
    <enterprise-beans>
    <session-deployment name="HolaMundoEJB" location="HolaMundoEJB" local-location="HolaMundoEJB_HolaMundoEJBLocal" local-wrapper-name="HolaMundoEJBLocal_StatelessSessionBeanWrapper6" remote-wrapper-name="HolaMundoEJB_StatelessSessionBeanWrapper7" persistence-filename="HolaMundoEJB.home_default_group_1">
    </session-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping name="<default-ejb-caller-role>" impliesAll="true" />
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>
    I'm trying to invoke the ejb in a servlet by doing the following:
    public void doGet(HttpServletRequest request, ....
    Context context = new InitialContext();
    HolaMundoEJB helloWorld =
    (HolaMundoEJB)context.lookup("java:com/env/ejb/HolaMundoEJB");
    String respuesta = helloWorld.sayHello("David");
    When i invoke the servlet I catch a NamingException whose message says something
    like this ....java:com/env/ejb/HolaMundoEJB not found in webLlamaEJB
    I tried different paths for the lookup but nothing....
    Can anyone help me with this topic? Thank you.

    Please try the following code:
    HelloEJBBean.java:
    @Stateless(name="Hello")
    @Remote(value={Hello.class})
    public class HelloEJBBean implements Hello {  ... }
    hello.jsp:
    Context ctx = new InitialContext();
    Hello h = (Hello)ctx.lookup("ejb/Hello");
    web.xml:
    <ejb-ref>
    <ejb-ref-name>ejb/Hello</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <remote>fi.kronodoc.test.model.Hello</remote>
    </ejb-ref>
    i think you should also define jndi mappings for the references in orion-ejb-jar.xml and orion-web.xml but for some reason it seems to be working also without these.

  • How to send the values from servlet to jsp

    hi folks,
    I need to send a lot of values from servlet to jsp so that i can display the values in jsp. Any sollution for this. Its very urgent.
    Thanks in advance

    Hi lieo,
    Can u send me the sample code for that.
    Thank q

  • Parameter passing from servlet to jsp page

    Hi
    I m facing problem of parameter passing from servlet to jsp ..
    plz help me...
    I m using as ...
    in servlet code I m using ...
    request.setAttribute("string",parameter);
    and in jsp..
    request.getParameter("string");
    regard's
    JAI KUMAR

    Hi Jaykumar
    You should use
    <%= request.getAttribute("sting") %> or
    ${string}
    in your jsp. I think you are trying to retrive the parameter instead of attribute.
    Thanks

  • Pass data from servlet to jsp using sendRedirect

    Hi,
    I am passing data from servlet to jsp using forward method of request dispatcher but as it doesn't change the url it is creating problems. When ever user refreshes the screen(browser refresh) it's re-loading both servlet and jsp, which i don't want to happen. I want only the jsp to be reloaded.
    Can I pass data from servlet to jsp using sendRedirect in this case. I also want to pass some values from servlet to jsp but without using query string. I want to set some attributes and send to jsp just like we do for forward method of request dispatcher.
    Is there any way i can send data using attributes(without using query string) using sendRedirect? Please let me know

    sendRedirect is meant as a true redirect. meaning
    you can use it to redirect to urls not in your
    context....with forward you couldn't pass information
    to jsps/servlets outside your own context.Actually, you can:
    getServletContext().getContext("/other").getRequestDispatcher("/path/to/servlet").forward(request, response)I think the issue here is that the OP would like to have RequestDispatcher.forward() also update the address in the client's browser. That's not possible, AFAIK. By the time the request is forwarded, the browser has already determined the URL of the servlet, and the only I know of way to have the browser change the URL to the forwarded Servlet/JSP is to send a Location: header (i.e. sendRedirect()). Remember that server-side dispatching is transparent to the client. Maybe there's some tricky stuff you can do with JavaScript to change the address in the address bar without reloading the page?
    Brian

  • How to send a message from Servlet to JSP

    Dear all,
    I have JSP, with JavaScript (AJAX). If the user click on the button, the text will be sent to a Servlet parsed by doGet() and the user get a response to his input, without reloading a page.
    How can I send a message to the users (JSP) from Servlet, if he didn't clicked any button and to other visitor of the page also? Is it possible? I think like a chat, the server sends a message to all users who are subscribed.
    I don't know, what should I get from user, maybe session, that I could send him personal or common messages in his textarea. I should also invoke some JavaScript function to update his page. I have met some chats, you don't do nothing and get messages. It is also without a JavaScript timer, which invokes doGet() method. Asynchronous, only when there is a message.
    Please help me with a problem.
    Thanks in advance.

    Hai ,
    You can send any message through response.sendRedirect();
    here is the coding try it
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class SimpleCounter extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();
    String username="java";
    res.sendRedirect("http://localhost:8080/yourprojectname/jspfile.jsp?username="+username);
    }

  • Returning ResultSet from servlet to jsp - java.lang.NullPointerException

    Hey all, i've been stuck on this for too long now...just trying to return a ResultSet from a servlet to jsp page.
    Had a bunch of problems earlier...which i think were fixed but...now i get a "java.lang.NullPointerException" in my jsp page when i try to get elements from the ResultSet object.
    Here is the latest version of my code:
    Servlet:
    String QueryStr="select ProdName from products";
    Statement stmt=conn.createStatement();
    rs=stmt.executeQuery(QueryStr); //get resultset
    sbean.setInventory(rs); //set ResultSet in bean
    req.getSession(true).setAttribute("s_resbean",sbean); //create session/request variable, set to bean
    Bean:
    package beans;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    public class SearchBean extends HttpServlet{
         private int searchFlag=0;
         private ResultSet inventory;
         public SearchBean(){
         public int getSearchFlag(){
         return searchFlag;
         public ResultSet getInventory(){
              return inventory;
         public void setInventory(ResultSet rs){
              this.inventory=rs;
         public void setSearchFlag(){
              this.searchFlag=1;
    jsp:
    <%@ page language="java" import="java.lang.*,java.sql.*,javax.sql.*,PopLists.PopInvLists,beans.SearchBean"%>
    <jsp:useBean scope="session" id="s_resbean" class="beans.SearchBean" />
    <% ResultSet categories=PopInvLists.getCat();
    ResultSet manuf=PopInvLists.getManuf();
    ResultSet supplier=PopInvLists.getSupplier();
    ResultSet cars=PopInvLists.getCars();
    ResultSet search=(ResultSet)request.getAttribute("s_resbean");
    %>
    <%     while(search.next()){
         String pname=search.getString("ProdName");
    %>
    It craps out when i try to loop through the "search" ResultSet.
    I can loop through the rest of the ResultSets no problem....just this one doesn't work because it's set in a servlet, not a simple java class.
    Just to clarify, i am populating some dropdown lists on entry to the screen, which the user will use to perform a search. Once the search btn is clicked, the servlet is called, gets the request info for the search, performs search, and returns the resultset to the original screen. I want to eventually display the result under the search criteria.
    Someone....Please Please please tell me how to get this working...it should be very simple, but i just can't get it to work.
    Thanks in advance,
    Aditya

    req.getSession(true).setAttribute("s_resbean",sbean); //create session/request variable, set to beanHere you add an attribute to the session.
    ResultSet search=(ResultSet)request.getAttribute("s_resbean");Here you try to get the attribute from the request. Naturally it isn't there because you added it to the session, not the request. Despite your comment in the first line of code, a session is not a request. And vice versa.

  • Error message from servlet to jsp

    Hi again,
    I have servlet and check error on this servlet then i would like
    to send error message to jsp page.Every error message will send to
    same JSP page.So JSP must receive message from Servlet.Can i do this?
    Please give me details and some sourcecode.I will appreciate for your helps.

    you could do something like this..
    request.setAttribute("error", stringErrormessage);
    Then in the jsp just do
    <%= request.getAttribute("error") %>
    That will print an errormessage.
    Basically, by setting anything on the request and then redirecting to that page you cn display it...
    //Johan

  • Creating files from servlets or jsp

    The issue that I have is this
    I've been working with eclipse, netbeans, tomcat, glassfish, servlets and jsps.
    I have a little servlet/jsp web application that create few files from the servlet. Those files I need to make them visible to the browser because they are the end result of the servlets/jsp work.
    When I run the server from netbeans/eclipse they deploy the war file into tomcat/glassfish server and run the app.
    So far there is no problem here, just that.. the files created with the app are created into the project folder.
    If I manually run the server, those files are created in the folder from I started the server, so what I did is get into the deployed/unpacked war and from there start the server.
    Only that way I could make those files visibles to download.
    Is there a better way to do this? (of course, it must be, but I don't know how).
    What I want is, deploy the web-app and make the app create those files at the same folder of the web-app to allow those file could be downloaded, no matter from where or how the server is started.
    In the near future I need to install few web-apps like this at the same server, so I can't still starting the server from the web-app folder (as I did it until now).
    I read about the request.getContextPath(); but it return no the real address just the context address (something like "/my_app"), so when I use that address to create a file, what I get is something lik "/my_app/myFile.txt".
    I hope you can give some advices of how to solve my issue.
    Thanks in advance

    830896 wrote:
    Right now I know the absolute path to the tomcat/glassfish where the web-app is deployed, so I can use that address, but in the future that web-app could be deployed in another server and I can't know what address does it have.
    I wonder if there exists a way to know the current absolute address of the web-app, or a way to create, "%this-web-app-absolute-addres%/someDir/myNewFile.txt"No, you're solving the wrong problem. Don't store files you create in the context of the web application, or even in the context of the application server. Store them somewhere else entirely. Then the person who configures the web application just has to set up the name of the directory where they are stored as a variable for your application.

  • Sending attachment from servlet or jsp

    Dear Friends,
    I downloaded javamail api and I have seen the sendfile.java, which is used to send attachments. it is working fine. I can able to run that program from command prompt like this :=
    c:>java sendfile [email protected] [email protected] mail.smtp.net c:/hello.java true
    It is working fine from console (command prompt)
    How can i execute that file on browser (i have to run as a servlet file or from jsp file).
    please help me how can i pass the emailids, file etc., if i want to use this program as servlet file or as jsp program.
    If anyone having idea, please share ur ideas.
    your kind cooperation would be greatly appreciated.
    Thanks in advance.
    Looking forward to hearing from you.
    Yours
    Rajesh
    ==
    program is like this (which is in javamail home ..demo directory
    ==
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    * sendfile will create a multipart message with the second
    * block of the message being the given file.<p>
    * This demonstrates how to use the FileDataSource to send
    * a file via mail.<p>
    * usage: <code>java sendfile <i>to from smtp file true|false</i></code>
    * where <i>to</i> and <i>from</i> are the destination and
    * origin email addresses, respectively, and <i>smtp</i>
    * is the hostname of the machine that has smtp server
    * running. <i>file</i> is the file to send. The next parameter
    * either turns on or turns off debugging during sending.
    * @author     Christopher Cotton
    public class sendfile {
    public static void main(String[] args) {
         if (args.length != 5) {
         System.out.println("usage: java sendfile <to> <from> <smtp> <file> true|false");
         System.exit(1);
         String to = args[0];
         String from = args[1];
         String host = args[2];
         String filename = args[3];
         boolean debug = Boolean.valueOf(args[4]).booleanValue();
         String msgText1 = "Sending a file.\n";
         String subject = "Sending a file";
         // create some properties and get the default Session
         Properties props = System.getProperties();
         props.put("mail.smtp.host", host);
         Session session = Session.getDefaultInstance(props, null);
         session.setDebug(debug);
         try {
         // create a message
         MimeMessage msg = new MimeMessage(session);
         msg.setFrom(new InternetAddress(from));
         InternetAddress[] address = {new InternetAddress(to)};
         msg.setRecipients(Message.RecipientType.TO, address);
         msg.setSubject(subject);
         // create and fill the first message part
         MimeBodyPart mbp1 = new MimeBodyPart();
         mbp1.setText(msgText1);
         // create the second message part
         MimeBodyPart mbp2 = new MimeBodyPart();
    // attach the file to the message
         FileDataSource fds = new FileDataSource(filename);
         mbp2.setDataHandler(new DataHandler(fds));
         mbp2.setFileName(fds.getName());
         // create the Multipart and its parts to it
         Multipart mp = new MimeMultipart();
         mp.addBodyPart(mbp1);
         mp.addBodyPart(mbp2);
         // add the Multipart to the message
         msg.setContent(mp);
         // set the Date: header
         msg.setSentDate(new Date());
         // send the message
         Transport.send(msg);
         } catch (MessagingException mex) {
         mex.printStackTrace();
         Exception ex = null;
         if ((ex = mex.getNextException()) != null) {
              ex.printStackTrace();

    Hi,
    your sendmail.jsp would look like that:
    <%@ page import="java.util.*,java.io.*,javax.mail.*,javax.mail.internet.*,javax.activation.*" %>
    <%
    String to = request.getParameterValues("to")[0];
    String from = request.getParameterValues("from")[0];
    String host = request.getParameterValues("host")[0];
    String filename = request.getParameterValues("filename")[0];
    String msgText1 = "Sending a file.\n";
    String subject = "Sending a file";
    // create some properties and get the default Session
    Properties props = System.getProperties();
    props.put("mail.smtp.host", host);
    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(debug);
    try {
    // create a message
    MimeMessage msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address = {new InternetAddress(to)};
    msg.setRecipients(Message.RecipientType.TO, address);
    msg.setSubject(subject);
    // create and fill the first message part
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText(msgText1);
    // create the second message part
    MimeBodyPart mbp2 = new MimeBodyPart();
    // attach the file to the message
    FileDataSource fds = new FileDataSource(filename);
    mbp2.setDataHandler(new DataHandler(fds));
    mbp2.setFileName(fds.getName());
    // create the Multipart and its parts to it
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    // add the Multipart to the message
    msg.setContent(mp);
    // set the Date: header
    msg.setSentDate(new Date());
    // send the message
    Transport.send(msg);
    } catch (MessagingException mex) {
    mex.printStackTrace();
    Exception ex = null;
    if ((ex = mex.getNextException()) != null) {
    ex.printStackTrace();
    %>
    which you can call as: sendmail.jsp?to=...&from=...&host=...&filename=...
    so you may need to create a HTML file containing the necessary form.

  • Database query ResultSet from servlet to JSP page

              Hi there,
              I have an Access 2000 database. I am running Apache and Tomcat on Windows Me.
              I would like to know if it is possible for me to use a Servlet to search the
              database (I know this bit is possible!), but then I would like the servlet to
              forward to a jsp page which will then display the ResultSet that the servlet has
              retrieved, i.e. when forwarding from a servlet to a jsp, is it possible for the
              jsp page to have access to the servlet's data? I know that it gets access to
              the response and request objects, but what about a ResultSet?
              Sorry it this sounds a little silly - i am a bit of a newbie.
              Thanks in advance for your help,
              SJ
              

    HttpServletRequest.setAttribute let's you share data for a particular
              request. When you call forward you can store the resultset in the request.
              Make sure your JSP does close the result set though, because what you are
              trying to do doesn't sound good :)
              If you want to share data across the session, take a look at the HttpSession
              object.
              read through the servlet specification, it is fairly easy to read and will
              give you all the info you need
              Filip
              ~
              Namaste - I bow to the divine in you
              ~
              Filip Hanik
              Software Architect
              [email protected]
              www.filip.net
              "SJ" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi there,
              >
              > I have an Access 2000 database. I am running Apache and Tomcat on Windows
              Me.
              > I would like to know if it is possible for me to use a Servlet to search
              the
              > database (I know this bit is possible!), but then I would like the servlet
              to
              > forward to a jsp page which will then display the ResultSet that the
              servlet has
              > retrieved, i.e. when forwarding from a servlet to a jsp, is it possible
              for the
              > jsp page to have access to the servlet's data? I know that it gets access
              to
              > the response and request objects, but what about a ResultSet?
              >
              > Sorry it this sounds a little silly - i am a bit of a newbie.
              >
              > Thanks in advance for your help,
              >
              > SJ
              

  • Passing database results from servlets to jsp

    Hi everyone,
    I have been trying to do what i thought would be a very simple thing...perform a search based on some criteria, and return the query result back to be displayed on a jsp page.
    I have a jsp page where some dropdown lists are populated on entry to the page. This works fine. I want to (eventually!) perform the search based on what is selected in these dropdowns. When i click the search button, i invoke a servlet called "SearchInventory.java" which gets the result. I then store this result in an ArrayList object. I then set a bean property (bean name->SearchBean, property->inventory) from within the servlet, and redirect back to the search page. This works if the query only gets back one column.
    Unfortunately, when i ask for more than one column in the query, i get a "java.lang.NullPointerException" error.
    Here is my code for all segments:
    JSP:
    <%@ page language="java" import="java.util.ArrayList,java.lang.*,java.sql.*,javax.sql.*,PopLists.PopInvLists,beans.SearchBean"%>
    <%
    SearchBean sbean=new SearchBean();
    ArrayList myAry=sbean.getInventory();
    int size=myAry.size();
    %>
    <%
              for(int i=0;i<size;i++){
                   String pname=(String)myAry.get(i);
         %>               
    <%}%>
    Servlet:
    String QueryStr="select ProdName,ManufName from products";// where ProdID="+ProdID;
    Statement stmt=conn.createStatement();
    rs=stmt.executeQuery(QueryStr);
    while(rs.next()){
         rowAry.add(rs.getString(1));
         rowAry.add(rs.getString(2));
         rowSetAry.add(rowAry.clone());
    sbean.setInventory(rowSetAry);
    req.getSession(true).setAttribute("s_resbean",sbean);
    res.sendRedirect("/DBTest/SearchInventory.jsp");
    In the servlet, i have also tried the following method of redirecting back to jsp page:
    String url="/SearchInventory.jsp";
    RequestDispatcher dispatcher=getServletContext().getRequestDispatcher(url);
    dispatcher.forward(req,res);
    ...this gives me a java.lang.ClassCastException
    here is my "bean" class:
    public class SearchBean extends HttpServlet{
         private int searchFlag=0;
         private static ArrayList inventory;
         public static ArrayList getInventory(){
              return inventory;
         public void setInventory(ArrayList rs){
              this.inventory=rs;
    When i perform a query that selects just one column, and doesn't use any sort of search fields for selecting, it does seem to work. for eg, : "select ProdName from products" as the query will return the product names successfully.
    Now, i realize what i'm doing is not correct....however, i don't know what the correct way of doing this is. Can someone please please show me how i should be going about doing all of this? It really shouldn't be difficult, but I just can't seem to get it to work.
    Thanks in advance,
    Aditya

    U have instantiated a search bean and populated its member variable i.e Array list , and added that bean to the session as an attribute. Then again why u need to instantiate the search bean in the jsp page.
    What has to be done.
    In the jsp page instead of instantiating the search bean ,get the search bean from the session attribute.
    statement to be removed : SearchBean bean=new SearchBean()
    statement to be added : SearchBean bean = session.getAttribute("bean");

  • How to pass a JavaBean from servlet to JSP?

    Hi there,
    I am working on a project that needs to handle quite a few client requests and I want to use the Front Controller pattern that is described in the J2EE pattern page.
    The steps described in the front controller pattern is that:
    1. A servlet (controller) process the client request.
    2. It calls the appropriate cammand object and the cammand object gets the data from the data source and returns a JavaBean that contains the required data.
    3. The servlet dispatch to the appropriate View (jsp page)
    4. The JSP page displays the data in the JavaBean to the user.
    However, I don't know how to pass the JavaBean from the servlet to the JSP page when the servlet forwards the control to the JSP page. Should I make the JavaBean with a request scope or higher? If so, how to uses it in the JSP page? Just refer by the ID of the JavaBean.
    If any one knows there is an example or tutorial on how to use this pattern, please let me know.
    Thank you !
    Regards
    Edmund

    Could you please give more info? i tried to do this, but always get a "Class not found exception":
    response$jsp.java:65: Class org.apache.jsp.TestBean not found. TestBean bean = null;
    although the class TestBean (no package name => defalt package) is in the WAR file and the Servlet seems to instantiate it (otherwise an exception would occur sooner in the TestServlet code).
    my JSP code is:
    <%@ page language="java" info="Response page" %>
    <jsp:useBean id="bean" class="TestBean" />
    <%
    TestBean bean2 = (TestBean) request.getAttribute("TheBean");
    %>
    <html>
    <body>
    Your value: <%= bean2.getValue() %><BR>
    My val: <%= bean2.getNewValue() %><BR>
    <P>
    Date: <%= new Date() %>
    <P>
    Neuen Wert eingeben
    </body>
    </html>
    --------------

  • Can't pass bean or request attribute from servlet to JSP

    Hi,
    I have a web app that starts with a file upload page that uses commons io fileUpload, passes the info on to a servlet. Then the servlet passes its info on to a JSP.
    I can upload the file onto the web app successfully. I also can call that uploaded file directly from the JSP (i.e. bypassing the servlet) without problem. But if I try to chain all 3 together while passing the url for the file directly as an attribute or as a bean containing file's url, I get premature end of file or can't find the property in the bean. I'm not sure what I'm doing wrong.
    the error message:
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: Premature end of file.
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
         servlet.UploadServlet.processRequest(UploadServlet.java:329)
         servlet.UploadServlet.doPost(UploadServlet.java:363)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    javax.servlet.ServletException: javax.servlet.jsp.JspException: Premature end of file.
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
         org.apache.jsp.clinTrialsEditor_jsp._jspService(clinTrialsEditor_jsp.java:144)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
         servlet.UploadServlet.processRequest(UploadServlet.java:329)
         servlet.UploadServlet.doPost(UploadServlet.java:363)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    org.xml.sax.SAXParseException: Premature end of file.
         org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
         org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
         org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSource(ParseSupport.java:227)
         org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSourceWithFilter(ParseSupport.java:193)
         org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseReaderWithFilter(ParseSupport.java:199)
         org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseStringWithFilter(ParseSupport.java:206)
         org.apache.taglibs.standard.tag.common.xml.ParseSupport.doEndTag(ParseSupport.java:138)
         org.apache.jsp.clinTrialsEditor_jsp._jspx_meth_x_parse_0(clinTrialsEditor_jsp.java:189)
         org.apache.jsp.clinTrialsEditor_jsp._jspService(clinTrialsEditor_jsp.java:88)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
         servlet.UploadServlet.processRequest(UploadServlet.java:329)
         servlet.UploadServlet.doPost(UploadServlet.java:363)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    Code from the servlet:
    String dName = "http://localhost:8084/fileUploadApp/faces/";
    url = dName + fileName;
    beans.FileInfo.setFileName(fileName);
    request.setAttribute("fileInfo", new FileInfo());
    beans.FileInfo.setDName(dName);
    beans.FileInfo.setDirName(dirName);
    beans.FileInfo.setUrl(url);
    File saveTo = new File(dirName + fileName);
    //if I use the next 2 lines I get "can't resolve symbol - create field, local var or parameter FileInfo"
    FileInfo fileInfo = new beans.FileInfo();
    request.setAttribute("fileInfo", FileInfo); //error here
    request.setAttribute("myUrl", url);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/clinTrialsEditor.jsp");
    dispatcher.forward(request, response);
    on JSP
    <jsp:useBean id="fileInfo" class="beans.FileInfo" scope="request"/>
    <jsp:setProperty name="fileInfo" property="*"/>
    <%--<c:import url="http://localhost:8084/fileUploadApp/faces/lowVision.xml" var="url" /> --%> <c:import url="${myUrl}" var="url" />
    <x:parse xml="${url}" var="clin" />
    etc...x:set with xpath expressions
    Can anyone spot my error(s)?
    Thanks for the help!

    Thanks for your reply, Ram.
    I made the change but I get an error "Unable to find a value for "fileName" in bean of type beans.FileInfo"
    Here's the bean:
    package beans;
    public class FileInfo {
    private static String fileName;
    private static String dirName;
    private static String dName;
    private static String url;
    /** Creates a new instance of FileInfo */
    public FileInfo() {
    public static void setFileName(String fn){
    fileName = fn;
    public static String getFileName(){
    return fileName;
    public static void setDirName(String dn){
    dirName = dn;
    public static String getDirName(){
    return dirName;
    public static void setDName(String d){
    dName = d;
    public static String getDName(){
    return dName;
    public static void setUrl(String u){
    url = u;
    public static String getUrl(){
    return url;
    Pertinent parts of servlet:
    String dirName = "C:/MyNBProjects/fileUploadApp/web/"; //save file to web app then convert to url so it can be called to show it on next page
    String dName = "http://localhost:8084/fileUploadApp/faces/";
    url = dName + fileName;
    FileInfo fileInfo = new FileInfo();
    fileInfo.setFileName("fileName");
    fileInfo.setDName("dName");
    fileInfo.setDirName("dirName");
    fileInfo.setUrl("url");
    request.setAttribute("fileName", fileName);
    request.setAttribute("url", url);
    request.setAttribute("fileInfo", fileInfo);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/clinTrialsEditor.jsp");
    dispatcher.forward(request, response);
    jsp:
    <jsp:useBean id="fileInfo" class="beans.FileInfo" scope="request"/>
    <jsp:setProperty name="fileInfo" property="*"/>
    url = <c:out value="${url}" />
    //works; not part of bean
    fileName = <c:out value="${fileName}" />
    //works; not part from the bean
    fileInfo.fileName = <jsp:getProperty name="fileInfo" property="fileName" />
    //doesn't work
    <%--fileName = <c:out value="${fileInfo.fileName}" /> //doesn't work
    Can you spot the error(s)?
    Thanks for your help.

  • Capture Unix Terminal TTY from Servlet or JSP

    I have a WEB Application (Servlets/JSP), that run in Tomcat. This aplication serve pages to IE and Links (Text Browser). I need that browser send a tty name, in case to use unix sco links, to servlet. How to do this? Help me please!!!!!

    From your servlet, you can try this...
    String browserType = request.getHeader("User-Agent")
    ...and see if this tells you whether or not you're using Lynx

Maybe you are looking for