Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Confused about setting up JSP

  1. #1
    Member
    Join Date
    Jun 2010
    Posts
    75
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Confused about setting up JSP

    As far as I can figure out, I have set up my server connection correct, because when I go to http://localhost:8080/ it takes me to the Tomcat test page that says I have set up my server connection correctly. However, when I change the location of the index.jsp page from the standard \webapps\ROOT to a folder that I created, \webapps\ROOT\jpages, the page will not display when I go to http://localhost:8080/jpages/index.jsp.

    I'm not sure that I have everything set up correctly, even though I followed the installation and set-up instructions exactly.

    I have other question about how to get JSP to work with a JavaBean, but I have to first resolve these issues before I ask them. I have an hunch that some of my problem will be resolved once I figure out how to access index.jsp wherever I put it, but I can't be sure until I can do that.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Confused about setting up JSP

    Its been a while since I've used Tomcat, but the directory doesn't sound correct. You should double check to make sure this directory is the correct location to place your servlets/jsp files (which I'd guess is the webapps folder, not in the ROOT folder

  3. #3
    Member
    Join Date
    Jun 2010
    Posts
    75
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Confused about setting up JSP

    Quote Originally Posted by copeg View Post
    Its been a while since I've used Tomcat, but the directory doesn't sound correct. You should double check to make sure this directory is the correct location to place your servlets/jsp files (which I'd guess is the webapps folder, not in the ROOT folder
    I figured out part of the problem: I did have the right directory, but the text editor I was using (Notepad) was not saving my JSP files with the .jsp extension, but with a .jsp.txt extension.

    I can change the extension manually from the command line, but that is, to say the least, slightly inconvenient. Is there a way to get Notepad to stop appending the .txt extension to the files I save with the .jsp extension?

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Confused about setting up JSP

    I think you should look into using a proper IDE like Eclipse or Netbeans for this kind of stuff. That would also give you the power of inline validation.

    When it comes to adding a Java bean/class to the request/session so you can use it in your JSP file all you need to do is this.

    final MyJavaBean myJavaBean = new MyJavaBean();
    request.setAttribute("nameOfTheBean", myJavaBean);

    Now in your JSP all you need to do is get the bean off the request.

    final MyJavaBean myJavaBean = (MyJavaBean) request.getAttribute("nameOfTheBean");

    Now this is not really best practise and instead you should use something like JSTL for this.

    Have a look at JSTL 1.0: What JSP Applications Need, Part 2 - O'Reilly Media

    // Json
    Last edited by Json; September 17th, 2010 at 05:16 AM.

Similar Threads

  1. Java File IO question :confused:
    By byebyebye in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: August 17th, 2010, 06:45 AM
  2. Ayudame! :confused:
    By wasaki in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 22nd, 2010, 10:37 AM
  3. [SOLVED] Prime number generator program in Java
    By big_c in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 27th, 2009, 12:08 PM
  4. Replies: 3
    Last Post: February 26th, 2009, 03:04 AM
  5. Confusion with C/C++
    By Eric in forum Java Applets
    Replies: 0
    Last Post: December 22nd, 2008, 02:18 PM