Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Can a jsp form run without a servlet etc?  RSS feed

 
Ranch Hand
Posts: 505
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to clean up my codes that was hosted with my web hosting company.

But, when I got to a form which is in jsp and it is linked to a servlet, I couldn't find that class file, as what I could find for another form.

I then emailed the support why is it that I couldn't find that file and he just replied that I do not need to have java class to run it.

However, I remember I did have a servlet for that form.

I feel quite disturbed that the class file could disappear and how then the form could still be submitted normally?

Over these 9 years, I was focusing on building up the site that my stuff just accumulated and I couldn't find the original source code.

I would like to know if there is any way running the .war file could give me back the java class file so that I can see what is the source code like?

I would also like to seek advice from the experts here do we just upload the ROOT.war to Tomcat public/html and all the compile code with JSP and servlet etc will extract on its own ?

The package I subscribed to is a private JVM with shared IP address.

Another thing is will it be a good idea to do remote connecting to the database residing in my web host for testing my code in my browser; since I can't still get MYSQL running in my local computer and I can't go on wasting time like that.

Hope to get some help here regarding above.

Thanks.



 
Sheriff
Posts: 13480
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you don't seem to understand that a JSP essentially is a servlet then I have my doubts about whether you understand how a form submission gets routed to a servlet that handles the form submission request.

Describe how you came to the conclusion that the servlet class was somehow missing. Tell us exactly where you looked and why you looked there. Normally, you'd first look in web.xml to see how URLs are mapped. From there, you can tell if you're using some kind of framework like Struts or Spring MVC and then continue searching from there.

Can you actually submit the form and get a response? If so, then the servlet isn't missing; you just don't know where to look.
 
tangara goh
Ranch Hand
Posts: 505
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Since you don't seem to understand that a JSP essentially is a servlet then I have my doubts about whether you understand how a form submission gets routed to a servlet that handles the form submission request.

Describe how you came to the conclusion that the servlet class was somehow missing. Tell us exactly where you looked and why you looked there. Normally, you'd first look in web.xml to see how URLs are mapped. From there, you can tell if you're using some kind of framework like Struts or Spring MVC and then continue searching from there.

Can you actually submit the form and get a response? If so, then the servlet isn't missing; you just don't know where to look.



I was told by the support that there isn't any class for that particular jsp I pointed out.

And so I am quite shock to get an reply like that.

I'd like to know if people normally extract the class files and upload to the public html ROOT folder when deploying it to web hosting company?

Perhaps they have messed up with my files that they don't know where it is now.....
 
Junilu Lacar
Sheriff
Posts: 13480
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer this question first: when you bring up that particular form in your browser, can you successfully submit the form and get back a valid response? If so, there is nothing missing. Whether or not your war or jar file was unpacked when it was deployed to the server is irrelevant.
 
tangara goh
Ranch Hand
Posts: 505
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Answer this question first: when you bring up that particular form in your browser, can you successfully submit the form and get back a valid response? If so, there is nothing missing. Whether or not your war or jar file was unpacked when it was deployed to the server is irrelevant.



Of course the form can be sent or submitted by user over the 9 years I am with this hosting company hence I do not know why the technical support said I don't have a class file for that jsp.

What do you think ?

I'd like to know do people unpack the .war files themselves or hand it to the web hosting company people to unpack and put it in the relevant directory in Tomcat ?
 
Saloon Keeper
Posts: 5504
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like a problem the hosting company has nothing to do with. On a private JVM, you are responsible for deployments and keeping track of files; I'm surprised they even went so far as to look into whether or not some particular file is present. They wold have to dig quite deep to even know whether some form submission goes to a servlet or not.

But you haven't provided any information that would allow us to venture a guess what might be going on. That information would include file and directory information, wbeb app setup, URLs etc. etc.
 
Junilu Lacar
Sheriff
Posts: 13480
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

tangara goh wrote:Of course the form can be sent or submitted by user ... What do you think ?

I'd like to know do people unpack the .war files themselves or hand it to the web hosting company people to unpack and put it in the relevant directory in Tomcat ?


Usually, you just deploy a WAR file. I don't know why the hosting company wouldn't just deploy the WAR file either.

I don't think your question about unpacking is relevant to your main question because again, it doesn't matter: if you can submit the form then there is nothing missing aside from a few pieces of understanding, but that's you. What you have to do now, as Tim says, is give us the information we need to help you figure this out.

So next, answer this question: what URL is that form getting submitted to? That is, what does the <form> tag in that JSP look like? Paste it here exactly as it appears in the JSP so we can see it.
 
Junilu Lacar
Sheriff
Posts: 13480
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a fairly detailed article about different options for deploying to Tomcat. I'd bet a bent penny that there is nothing in there about unpacking the WAR file manually.

https://www.baeldung.com/tomcat-deploy-war
 
Sheriff
Posts: 67261
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "Java class file" what is it you are talking about? The .java file, or the .class file?
 
Bartender
Posts: 20775
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. First, to expand a little. When a URL request is made that resolves to a JSP, the JSP is compiled into java source code using a Tomcat component called JaSPer. The java source code is itself a servlet class definition, which is then compiled to produce a .class file, which is stored in Tomcat working storage (specifically, TOMCAT_HOME/work/yourwebappname/xxxxx.class, where "xxxxx" is the name of the servlet, including resource path). This also serves as a cache, so the JSP doesn't have to be compiled over and over again.

However, assuming that the real missing servlet was an actual java servlet compiled as part of creating a WAR, then there are probably 4 things that might be wrong:

A) Your JSP is dispatching to an improper resource path - not the resource path where the servlet class actually lives.

B) Your web.xml file is defective and doesn't have the proper logical-to-physical servlet mapping, which is essentially a variation of case A).

C) Your WAR is damaged. In this case, you need to create a new WAR and deploy it in place of the broken WAR.

D) Your WAR is improperly deployed. I consider this to be very likely, since Tomcat doesn't support simply tossing files into an "html ROOT" directory. Tomcat is a J2EE webapp server, capable of hosting multiple webapps concurrently. The common usage is that the webapps are deployed to the TOMCAT_HOME/webapps directory, but there are other ways to do it as well.

Every webapp MUST be in the form of a WAR. A WAR, in its purest form, is a specially-formed type of JAR file, which itself is a specially-formed type of ZIP file. A WAR must have a very specific directory organization and support files, as defined in the J2EE and JEE specs.

A deployed WAR inside Tomcat may be in one of 2 forms: A standard WAR file or an "exploded" WAR. An exploded WAR is simply a WAR that has been unzipped.

Again, Tomcat can host multiple webapps. Which webapp a given URL request will be dispatched to depends on the context path part of the incoming URL. That is, "http://myserver/mywebapp/webpage.jsp", for example. In this case "mywebapp" is the context path.

The convention by default is that each webapp will reside under a directory named TOMCAT_HOME/webapps/mywebapp, where "mywebapp" is the name of the WAR and is taken to also be the context path name. The special WAR name "ROOT", however, is mapped to the context path "/", since "/" is not a valid directory name. As distributed, Tomcat keeps its own webapp there, which must be replaced if you want to be able to access a webapp whose URL path is something like "http://myserver/webpage.jsp" instead of "http://myserver/mywebapp/webpage.jsp".

You can deploy a webapp into Tomcat in numerous ways. There is not one "right" way. You can use the Tomcat Management webapp to upload an deploy a WAR file from your desktop. You can copy a WAR file to TOMCAT_HOME/webapps. You can unzip a WAR file into TOMCAT_HOME/webapps/my_war_name, where again, "my_war_name" will serve as the basis of the URL context path. You can delete the TOMCAT_HOME/webapps/ROOT directory and replace it with a new ROOT directory containing an exploded WAR's files. By default, if you deploy a WAR file to Tomcat, by any of the applicable above mechanisms, Tomcat will automatically exploded it into a directory of the same basename as the WAR file.

What you cannot do, however, is just slap files out to TOMCAT_HOME/webapps and expect them to work.

And, up to, and including some early releases of Tomcat version 8, if a ".war" file and an exploded WAR directory of the same name existed in TOMCAT_HOME/webapps, the WAR file would be ignored even if it was more recent than the WAR directory.
 
Junilu Lacar
Sheriff
Posts: 13480
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim, while that's all good, OP has already confirmed that the form can be submitted successfully. If that's true, I seriously doubt anything is actually missing.

OP's original goal was to do some refactoring so I think its reasonable to think OP is looking for the JSP file or the .java file of the class that handles the request made when submitting that form.
 
Master Rancher
Posts: 4087
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, the source code was in the WAR file?
 
Junilu Lacar
Sheriff
Posts: 13480
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A lot of confusion in this thread. We have to consider that English is not OP's first language. That adds to the lack of clarity.

OP said he was trying to clean up code. That means source code. He also refers to "java class file" which, to Bear's point, is unclear. Is that supposed to be the .java file or the .class file?

Next, OP says the support guy told OP "you don't need the java class file." We don't know if that was what was actually said or just OP's interpretation.  Assuming the support guy knew what he was talking about, he meant the .java file because the WAR file would contain the .class file. OP already confirmed that he can successfully bring up the form in a browser and submit it so we know the .class file is not missing from the deployed WAR file.

What we don't know right now is how OP's source code is organized and what servlet that form gets submitted to. If OP answers my follow up questions we should be able to make some progress.
 
Oh the stink of it! Smell my tiny ad!
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!