simple jsp problem.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting simple jsp problem.
# 1  
Old 08-27-2010
simple jsp problem.

I have my jsp page located at
Code:
/install/apache-tomcat-5.5.29/webapps/jsp-examples/light/login.jsp

There fore i will have to use following url to access it.
Code:
 localhost:8080/jsp-examples/light/login.jsp

How would i make this little shorter like.
Code:
 localhost:8080/login.jsp

I m using apache tomcat server 5.5.29.

Last edited by pinga123; 08-27-2010 at 04:49 AM..
# 2  
Old 08-27-2010
I don't know a lot about JSP, but I think you should set an alias.

Check the links below: Oracle JSP in Apache JServ
Path Alias using tomcat
Configuring Web Clients

If none of them help you, maybe ask this question in a JSP forum.

Regards.
# 3  
Old 08-27-2010
A jsp problem is certainly not related to shell programming and scripting...I would help you though...

You need to add a Context description in the Tomcat configuration file, which is located at $TOMCAT_HOME/conf/server.xml. search for the <Host> element, add <Context> below it. like the following:
Code:
      <Host>
		<Context path="" docBase="/absolute/path/to/webapps/jsp-examples/light"/>
      </Host>

Leave the "path" attribute empty so you can access your web application using "localhost:8080/{your files under /absolute/path/to/webapps/jsp-examples/light}"
# 4  
Old 08-30-2010
Quote:
Originally Posted by kevintse
A jsp problem is certainly not related to shell programming and scripting...I would help you though...

You need to add a Context description in the Tomcat configuration file, which is located at $TOMCAT_HOME/conf/server.xml. search for the <Host> element, add <Context> below it. like the following:
Code:
      <Host>
        <Context path="" docBase="/absolute/path/to/webapps/jsp-examples/light"/>
      </Host>

Leave the "path" attribute empty so you can access your web application using "localhost:8080/{your files under /absolute/path/to/webapps/jsp-examples/light}"
its not working for me.Here is what i did.
I opened conf/server.xml
added following part into it.
restart the tomcat server.
Code:
<Host>
                <Context path="" docBase="/install/apache-tomcat-5.5.29/webapps/jsp-examples/light/"/>
      </Host>

while accessing localhost:8080/login.jsp.
i got following error

Code:
type Status report
message /login.jsp
description The requested resource (/login.jsp) is not available.

# 5  
Old 08-30-2010
I don't know where you put the code in the server.xml configuration file, I guess you might have put them in the wrong place. I have the following in my server.xml, and it works.
Code:
<Server port="8006" shutdown="SHUTDOWN">

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

<Service name="mysite">
    <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="mysite" defaultHost="127.0.0.1">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  resourceName="UserDatabase"/>
      <Host name="127.0.0.1"  appBase="webapps" unpackWARs="true" autoDeploy="true"  xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="/home/kevin/webapps/mysite" reloadable="true" />
      </Host>
    </Engine>
</Service>
</Server>

# 6  
Old 09-01-2010
Quote:
Originally Posted by kevintse
I don't know where you put the code in the server.xml configuration file, I guess you might have put them in the wrong place. I have the following in my server.xml, and it works.
Code:
<Server port="8006" shutdown="SHUTDOWN">

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

<Service name="mysite">
    <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="mysite" defaultHost="127.0.0.1">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  resourceName="UserDatabase"/>
      <Host name="127.0.0.1"  appBase="webapps" unpackWARs="true" autoDeploy="true"  xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="/home/kevin/webapps/mysite" reloadable="true" />
      </Host>
    </Engine>
</Service>
</Server>

I have made proper changes in server.xml
Code:
<Context path="" docBase="/install/apache-tomcat-5.5.29/webapps/light/milind_pages"/>

I can now able to access the url with The UNIX and Linux Forums - Learn UNIX and Linux from Experts.
but the problem is even if i put a correct credentials it doesnt redirect me to next page which is cgipage.jsp.

my code in login.jsp as follows do i need to change in the code after this configuration?
also want to tell here that login.jsp and cgipage.jsp are both in same location as
/install/apache-tomcat-5.5.29/webapps/light/milind_pages
Code:
<%@ page import="java.lang.*" language="java"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>

<%
        //Getting Username and Password from text box
        String username   = request.getParameter("username");
        String password  = request.getParameter("password");

        try
        {

         //Triming Username and Password
         String trim_Username  = username.trim();
         trim_Username= trim_Username.toLowerCase();
         String trim_Password =  password.trim();

         Connection conn=null;
         Statement stmt=null;
         ResultSet rs=null;
         String id  =  null;
         String pin =  null;
         String fullname =null;
         String role =null;

         Class.forName ("oracle.jdbc.driver.OracleDriver");
         conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "lightweight", "oracle");
                            // @machineName:port:SID,   userid,  password

        String sql = "select * from LIGHT_CRED where USERNAME='"+trim_Username+"'";

        stmt = conn.createStatement();
        rs = stmt.executeQuery(sql);

        while( rs.next() )
        {
         //Getting Username,Password,roll,Fullname from Database.
         id=rs.getString(1);
         pin=rs.getString(2);
         role=rs.getString(3);
         fullname=rs.getString(4);
         }

        if(trim_Username.equals(id) && trim_Password.equals(pin))
        {
 out.println("login successful");
        session.setAttribute("user",trim_Username);
        session.setAttribute("fullname",fullname);
        session.setAttribute("role",role);
        response.sendRedirect("cgipage.jsp");
        }
        else
        {
        out.println("incorrect username/password combination");
        }

}
catch(Exception e)
{
System.out.println(e.getMessage());
}
%>
<html>
<body>
<form action=login.jsp method=post>
<p align="center">
<BR>
Light Weight Manager V.1</p>
<table border="1" width="443" height="80" align=center>
<tr>
                <td height="37" width="177">Username: </td>
                <td height="37" width="180"><input type=text size=20 name=username></td>
                <td height="37" width="64">&nbsp;</td>
        </tr>
        <tr>
                <td height="35" width="177">Password:&nbsp; </td>
                <td height="35" width="180"><input type=password size=20 name=password></td>
                <td height="35" width="64">
<input type=submit value="Log In"></td>
        </tr>
</table>
New Feature added for admin users.
CD changer:Admin user can now change the CD of Virtual Machine.
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
</body>
</html>

# 7  
Old 09-01-2010
I don't see anything wrong in your code, it should have worked.

Well, what errors did you get when it didn't redirect you to "cgipage.jsp"? did all your code compile fine?

I guess it might be that you were redirected to the expected page, but there're some errors in your "cgipage.jsp" page. I don't know...

You may check log messages under $TOMCAT_HOME/logs, and make sure your code compile.

Last edited by kevintse; 09-01-2010 at 10:06 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

simple wc problem

Hi there, Im sure there is a simple explanation for this but I have a file like this with no balnk lines peter paul john I run the command # var=`grep paul file.txt` # echo $var paul # echo $var | wc -l 1 but when I grep for a value that isnt in the file, i still... (4 Replies)
Discussion started by: rethink
4 Replies

2. Shell Programming and Scripting

Please help me with a simple problem

Hi, I have a very simple script like below: for n in 10 20 30 do for a in 30 40 50 60 70 80 do for r in 2 3 4 5 6 7 do m=$((r*a)) count=1 while do echo "a = " $a ", m = " $m ", n = " $n ... (2 Replies)
Discussion started by: Dark2Bright
2 Replies

3. Programming

Problem in reflecting changes made on a JSP File

I make some changes in a JSP file but the changes do not reflect on tomcat server. In my server.xml 'reloadable' paramtere is set to true. I even treid restarting the server. The changes still not reflect. The changes do reflect in a day or two. am not sure why this is happening. Shall... (3 Replies)
Discussion started by: Shikha Agrawal
3 Replies

4. Programming

Please I need your help about jsp and java

Hello.. is there any way to send a file or a string from jsp website to java program which all I will develope i remember that i can make socket connection between jsp and java but:confused::confused: I dont now how if there any website or booke explain that or if there another way ... (2 Replies)
Discussion started by: vip_a1
2 Replies

5. Shell Programming and Scripting

i want to edit my jsp page using script

hi I have one jsp file. i want to edit this jsp page using script. This jsp page contains ("insert into employee values('raja', 32, ' ');) i want to add empty column at the end of the line. i.e is that line should be (insert into employee values('raja', 32, ' ', ' ');) (2 Replies)
Discussion started by: nsundaram_cse
2 Replies

6. Shell Programming and Scripting

calling unix script from JSP???

Hi all, i have requirement where i need to call a unix script from a JSP code. my script should list all the csv files from a directory and then should upload the file names to an oracle table (using sqlloader). i tried using getRuntime function in JAVA to call my script and was successfully... (1 Reply)
Discussion started by: Bhups
1 Replies

7. Shell Programming and Scripting

Code conversion from JSP to PYTHON

Guys I need to convert a code from JSP (Java Tags are also there inside JSP) to PYTHON. I have OK kind of knowledge in PYTHON, but dont have a muck knowledge in JAVA/JSP. Any idea how to approach? Thanks in advance to all C Saha (1 Reply)
Discussion started by: csaha
1 Replies

8. UNIX for Dummies Questions & Answers

JSP on an HP UX-11

We have an HP UX-11 server running Unix and we wish to run Java Server Pages on this system. Can anyone see a reason why these pages will not work under this environment. Thanks for you help. Matthew (2 Replies)
Discussion started by: MLarra51
2 Replies

9. Shell Programming and Scripting

user creation using shell script for JSP

hello friends, I have problem. We want to create user from jsp(browser based) on our linux server. How we can do that ? or How do we create a user with shell programming by taking arguments and checking with the existing users and if the user exist it should display the message the user exists... (1 Reply)
Discussion started by: jarkvarma
1 Replies
Login or Register to Ask a Question