The Artima Developer Community
Sponsored Link

Java Answers Forum
Jsp import my own class HELP

3 replies on 1 page. Most recent reply: Aug 22, 2002 10:38 PM by aarunprabhu

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
chuck

Posts: 9
Nickname: chuckjava2
Registered: Jul, 2002

Jsp import my own class HELP Posted: Aug 1, 2002 12:16 PM
Reply to this message Reply
Advertisement
I've tried to import my own java file in this jsp file, so I can use the variables in the imported file. But it doesn't work. Please pay attention in theses lines.

1) <%@ page import="Assign5th.java" %> is this right? and the varibles in the imported file are p1, p2, p3, p4.

2) I've also tried to link the jsp file to another one so I <FORM ACTION="http://localhost/w10/Assign5th.jsp"> so when users press a buttom, (which will be created) the users are taken to another jsp file. I hope I am doing it right, Please help.

For the convenience I've included the first jsp below








<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Assign5th2</TITLE>
</HEAD>
<BODY BGCOLOR="#FDF5E6">
<H1 ALIGN="CENTER">Cis3270--Student Records--</H1>
<%@ page language="java" %>
<%@ page import="Assign5th.java" %>

<FORM ACTION="http://localhost/w10/Assign5th.jsp">


Student ID : <% =p1 %> <BR>
Last Name : <% =p2 %> <BR>
First Name : <% =p3 %> <BR>
Final Grade: <% =p4 %> <BR>


Don Hill

Posts: 70
Nickname: ssswdon
Registered: Jul, 2002

Re: Jsp import my own class HELP Posted: Aug 1, 2002 12:56 PM
Reply to this message Reply
I am not sure what you are trying to do, but if you want to call some code inside your jsp you should look at <jsp:usebean />

check out http://java.sun.com/products/jsp/html/jsptut.html
for more info.
HTH
> I've tried to import my own java file in this jsp
> file, so I can use the variables in the imported
> file. But it doesn't work. Please pay attention in
> theses lines.
>
> 1) <%@ page import="Assign5th.java" %> is this
> right? and the varibles in the imported file are p1,
> p2, p3, p4.
>
> 2) I've also tried to link the jsp file to another
> one so I <FORM
> ACTION="http://localhost/w10/Assign5th.jsp"> so when
> users press a buttom, (which will be created) the
> users are taken to another jsp file. I hope I am
> doing it right, Please help.
>
> For the convenience I've included the first jsp
> below
>
>
>
>
>
>
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
> Transitional//EN">
> <HTML>
> <HEAD>
> <TITLE>Assign5th2</TITLE>
> </HEAD>
> <BODY BGCOLOR="#FDF5E6">
> <H1 ALIGN="CENTER">Cis3270--Student Records--</H1>
> <%@ page language="java" %>
> <%@ page import="Assign5th.java" %>
>
> <FORM ACTION="http://localhost/w10/Assign5th.jsp">
>
>
> Student ID : <% =p1 %> <BR>
> Last Name : <% =p2 %> <BR>
> First Name : <% =p3 %> <BR>
> Final Grade: <% =p4 %> <BR>

Satheesh Kumar G

Posts: 1
Nickname: satheesh
Registered: Aug, 2002

Re: Jsp import my own class HELP Posted: Aug 6, 2002 4:11 AM
Reply to this message Reply
hai!
You cannot import a java file. You have to import a java class file with proper signature(i.e. qualified with package name). In that case, you instantiate an object for your class and can use your variable using that object.

aarunprabhu

Posts: 1
Nickname: aarunprabh
Registered: Aug, 2002

Re: Jsp import my own class HELP Posted: Aug 22, 2002 10:38 PM
Reply to this message Reply
Hi

i am currently working in JSP in Iplanet server
here i just created a folder Classes and given class path.
then in JSP i put only
<%@ page import="ForesightCommon.*"%>

here ForesightCommon is a package of my java program
u can directly create instance of any class in that
package in u'r subsequent lines of JSP

i.E

Pilot db=new Pilot();

here pilot is class in that package

dont get confued with too many do this alone.

Flat View: This topic has 3 replies on 1 page
Topic: Diff between JVM and JRE Previous Topic   Next Topic Topic: Chat room

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use