Solved

JSP @ page import question

Posted on 2010-11-18
33
554 Views
Last Modified: 2012-05-10
Hi,

I've been tasked with creating a dev site of an exiting JSP site.  So I'm going to make a www2 of the main site.  I'm brand new to JSP... I'm very proficient in ColdFusion.  So my first of many basic questions is this:

I duplicated the site but the pathing for java is now wrong.  The old site points to a folder called 'web'.  The new (dev) site points to a folder called web2.  How do I change the java (jsp) pathing?

In the index page I see the following code:
<%@ page import="com.monumental.trampoline.component.*" %>
<%@ page import="com.monumental.trampoline.navigation.*" %>

Can I hook into this site using Eclipse, and then start working with all this code?

Thanks ss very very very much.  ~Wendi
0
Comment
Question by:FrostyGirl
  • 17
  • 16
33 Comments
 

Author Comment

by:FrostyGirl
ID: 34164427
I suppose my basic question is:  Is there a type of master config file that I can edit?
0
 
LVL 27

Expert Comment

by:rrz
ID: 34165197
><%@ page import="com.monumental.trampoline.component.*" %>
><%@ page import="com.monumental.trampoline.navigation.*" %>  
These lines tell java where to look for the class files that the JSP uses.

Are you using something like
http://www2.mydomain.com 
in your browser ?  
If so, then create a simple test JSP file and put it into your web2 folder.
Try to access it with
http://www2.mydomain.com/test.jsp 
What happens ?
You could read  
http://download.oracle.com/javaee/5/tutorial/doc/bnadx.html 
0
 
LVL 27

Expert Comment

by:rrz
ID: 34165212
>create a simple test JSP file and put it into your web2 folder.  
and name the file   test.jsp
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:FrostyGirl
ID: 34165335
I received this:  The requested resource (/test.jsp) is not available.  404 test.jsp.  However, if I change the file extension to test.html then the page is found.
0
 

Author Comment

by:FrostyGirl
ID: 34165482
Okay, so I've found and know what the WEB-INF/web.xml file does.  Still no help.  
0
 
LVL 27

Expert Comment

by:rrz
ID: 34165490
Which JSP container are you using ?
0
 

Author Comment

by:FrostyGirl
ID: 34165522
No idea.  I'm reading tutorials now and other than knowing what a JSP container is (the theory of it), I know nothing more about them.
0
 
LVL 27

Expert Comment

by:rrz
ID: 34165575
Does the original site still work ?  Can you add a JSP to it ? If you can, then try running this page.
Server is <%= application.getServerInfo()%><br/> 
JSP version is <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion()%><br/> 
Servlet API is <%= application.getMajorVersion()%>.<%=application.getMinorVersion()%>
${"Hello JSP 2"}

Open in new window

0
 
LVL 27

Expert Comment

by:rrz
ID: 34165615
>Can I hook into this site using Eclipse, and then start working with all this code?
You can create a new Web project and copy your code into it. After making changes you and publish to server.
0
 

Author Comment

by:FrostyGirl
ID: 34166245
Results from running the code you provided:

Server is Apache Tomcat/5.0.28
JSP version is 2.0
Servlet API is 2.4 Hello JSP 2
0
 
LVL 27

Expert Comment

by:rrz
ID: 34166517
Ok, Tomcat is your JSP container.  
>I received this:  The requested resource (/test.jsp) is not available.  404 test.jsp.  
Did you get any other error messages ? Either in Tomcat's logs or Apache web server logs ?
>if I change the file extension to test.html then the page is found.  
Also try changing the name to something else. For instance if you change to  test.java  then the browser should ask you if you want to download the file.
0
 

Author Comment

by:FrostyGirl
ID: 34166680
Result from changing file name to test.java (on original server):

The page didn't download, it displayed this code (using chrome):

Server is <%= application.getServerInfo()%><br/>
JSP version is <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion()%><br/>
Servlet API is <%= application.getMajorVersion()%>.<%=application.getMinorVersion()%>
${"Hello JSP 2"}
0
 

Author Comment

by:FrostyGirl
ID: 34166720
running test.java on the new site instance (www2) resulted in this error (there was no page rendering below the error statement):

This page contains the following errors:

error on line 2 at column 2: StartTag: invalid element name
Below is a rendering of the page up to the first error.
0
 

Author Comment

by:FrostyGirl
ID: 34166746
More detailed error message for test.java  :::


The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

A name was started with an invalid character. Error processing resource 'http://www2.website.com/test.java'. Line 2, Pos...

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
-^
0
 

Author Comment

by:FrostyGirl
ID: 34166762
another example of www2 acting not as expected.

I have a page index3.jsp.  On www2 that page isn't found:  The requested resource (/index3.jsp) is not available.  But if I change the extension to .java, then the page is found and simply displays all of its code in the browser
0
 
LVL 27

Expert Comment

by:rrz
ID: 34166868
You should add the Apache Web Server zone to this question(as you did for your previous questions. Maybe one of those Apache experts can help you.  
Meanwhile look for a file called   server.xml  
It could be at  
 /usr/local/tomcat/conf/server.xml  
If you find it, then show us any <Host> tags in it.
0
 

Author Comment

by:FrostyGirl
ID: 34166976
<Host name="localhost" appBase="webapps">
<Context path="" docBase="/home/www/wwwwebsite.com/web" debug="1" reloadable="true" crossContext="false">
...........
 </context>
</host>

Can I add another host?  So it would be
<Host name="localhost" appBase="webapps">
<Context path="" docBase="/home/www/wwwwebsite.com/web2"
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167023
Yes add a <Host> tag for your new web app web2
0
 

Author Comment

by:FrostyGirl
ID: 34167045
Do I have to make a new <Host> name?  

<Host name="localhost2" appBase=webapps">  ???
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167058
But I think it needs a different name.
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167059
yes
0
 

Author Comment

by:FrostyGirl
ID: 34167245
I can't make changes to the server.xml file.  Won't let me simply by trying to edit the file.  
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167411
No, I am wrong. You should only one <Host> tag. Please leave the Host tag as it was before.
It is <Context> tag that should have another tag.

<Host name="localhost" appBase="webapps">
<Context path="" docBase="/home/www/wwwwebsite.com/web" debug="1" reloadable="true" crossContext="false">
...........
 </context>
<Context path="web2" docBase="/home/www/wwwwebsite.com/web2" debug="1" reloadable="true" crossContext="false">
...........
 </context>
</host>

Restart Tomcat.
Now try to browse to  http://www2.website.com/web2/test.jsp
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167431
I can't make changes to the server.xml file.  
Do you have permissions ?
0
 

Author Comment

by:FrostyGirl
ID: 34167443
Will do... as soon as i can figure out a way to edit the server.xml file.  I'm accessing remotely and the only tools I currently have are a controlPanel or trying to overwrite the file... which isn't working.
0
 

Author Comment

by:FrostyGirl
ID: 34167453
I don't have permissions.  I've tried changing the permissions... no dice.  I tried stopping the apache server.... also didn't work.
0
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 34167470
I made another error(forgot / in path). Should be  
<Host name="localhost" appBase="webapps">
<Context path="" docBase="/home/www/wwwwebsite.com/web" debug="1" reloadable="true" crossContext="false">
...........
 </context>
<Context path="/web2" docBase="/home/www/wwwwebsite.com/web2" debug="1" reloadable="true" crossContext="false">
...........
 </context>
</host>

Restart Tomcat.
Now try to browse to  http://www2.website.com/web2/test.jsp
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167498
>I tried stopping the apache server....  
Stopping Tomcat should be a separate command.
What is your hosting provider ?
0
 

Author Comment

by:FrostyGirl
ID: 34167515
RimuHosting.com
0
 

Author Comment

by:FrostyGirl
ID: 34167533
This is the webadmin control panel I'm dealing with:
http://rimuhosting.com/images/webminservices.jpg
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167554
You should delete(or rewrite) your lastest question. You are trying add a Context not a Host.
Meanwhile I am looking at Rimu
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167623
Look at  
http://rimuhosting.com/tomcat.jsp   
on that page we see  that you have to go to the command line
0
 
LVL 27

Expert Comment

by:rrz
ID: 34167705
I think the commands are
/etc/init.d/tomcat stop
and
/etc/init.d/tomcat start  

Are you able to find the command line ? I can't remember where it is located. Keep poking around in Webmin for the command shell.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem with Pie chart in Jsp 20 223
authenticate preemptively soap ui option 3 156
doubleChar java challenge 7 121
Books that can get me started on JAVA 2 105
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question