• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:21
CEST 10:21
KST 17:21
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Chinese SC2 server to reopen; live all-star event in Hangzhou4Weekly Cups (Oct 13-19): Clem Goes for Four0BSL Team A vs Koreans - Sat-Sun 16:00 CET6Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou The New Patch Killed Mech! Team Liquid Map Contest #21 - Presented by Monster Energy herO joins T1 Weekly Cups (Oct 13-19): Clem Goes for Four
Tourneys
SC2's Safe House 2 - October 18 & 19 INu's Battles #13 - ByuN vs Zoun Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $1,200 WardiTV October (Oct 21st-31st)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
Is there anyway to get a private coach? OGN to release AI-upscaled StarLeague from Feb 24 BW caster Sayle BSL Season 21 BW General Discussion
Tourneys
[ASL20] Semifinal B [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN Azhi's Colosseum - Anonymous Tournament
Strategy
[I] TvZ Strategies and Builds [I] TvP Strategies and Build Roaring Currents ASL final Current Meta
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread Dawn of War IV ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread The Chess Thread Things Aren’t Peaceful in Palestine Men's Fashion Thread
Fan Clubs
The herO Fan Club!
Media & Entertainment
Series you have seen recently... Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1423 users

The Big Programming Thread - Page 614

Forum Index > General Forum
Post a Reply
Prev 1 612 613 614 615 616 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 15 2015 21:03 GMT
#12261
On April 15 2015 13:41 FFGenerations wrote:
ok well i've given up trying to make it work this way for now. i sort of understand what you've been saying earlier about the autogenerated thing being fucked up. what you wrote totally flew over my head before, but you kept railing on about it until i started to understand. thanks all, you've been brilliant!

will move on to trying to parse it myself instead

Good that you're moving in the right direction .

Just a couple things so you don't get overly dissuaded. There's nothing inherently wrong with using auto-generated code, and in fact a lot of major frameworks will have you relying a bit on them (C# with ADO.NET comes to mind). The important thing is to understand why you're using an auto-generator, and how actually interact with it.

Overriding ToString() methods is also a valid option in many cases, and returning the main identifier for an object like a Name is definitely a good time to do it. Of course, in this circumstance it would be a band-aid solution, because inevitably you'll want other information from you objects, and you'll be right back to the same problem you started with.

Finally, parsing text may seem like a massive undertaking at first, but it's something you will be dealing with eventually if you're a programmer of any kind, so it's definitely something worthwhile to learn. Luckily for you, you're dealing with XML, which is basically designed to be parsed easily.
Average means I'm better than half of you.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-15 22:55:38
April 15 2015 22:33 GMT
#12262
i found a pretty crazy good tutorial



i done the basic one first which also shows it being done with Lists then was wondering why the fuck my nested xml wasnt working and then found the person had just uploaded this one, thank god

so ..... the next thing i'm going to find out is how "deep" into the xml file i need to go to get the data i want i guess, or how far i can simplify it before it fucks up on me. i tend to lean towards it being easy now but i might end up having to look at a plugin that jumps to the parts i want, or something, which would be annoying :D since i have 5 days left lol

the xml file starts off something like this

<ann>
- <anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<related-prev rel="related to" id="13312" />
- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>


so thats like

<ann>
<anime> (use @XmlValue here maybe to grab 'anime id' and 'anime name'? need to check what it does exactly)
<info></info>
<info></info> (how to deal with multiple infos? maybe @XmlValue will straight up work here too to grab 'info src'. or maybe the parser will return a List of infos in this case)
.....
</anime
</ann>
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:49:40
April 16 2015 01:32 GMT
#12263
hi, im a bit stuck on this bit

so from what i can gather Ann (top class) returns as a list of Anime objects

the Anime class should have multiple attributes though: name, id and List of Info objects

FIXED
+ Show Spoiler +

so right now i have it looking like this:

public class Anime {

private String id;
private String name;
private List<Info> infolist;
...
public List<Info> getInfolist() {
return infolist;
}

public void setInfolist(List<Info> infolist) {
this.infolist = infolist;
}
...
public Anime(String id, String name, List<Info> infolist) {
this.infolist = infolist;
this.id = id;
this.name = name;
}


this looks different to the Ann class where i have

public class Ann {

private List<Anime> Ann = new ArrayList<Anime>();

@XmlElement(name="anime")
public List<Anime> getAnn() {
return Ann;
}

public void setAnn(List<Anime> Ann) {
this.Ann = Ann;
}


after unmarshalling the xml file into Ann, i am able to perform

for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

this works.

however i am struggling to be able to access the Info list that should be in the anime class.

i guess the question is, how do i correctly set a list of Info as an attribute of the anime class

Anime class did look similar to Ann to begin with, as below, but i thought maybe that was wrong


public class Anime {

private String id;
private String name;
private List<Info> Anime = new ArrayList<Info>();
...
public Anime(String id, String name) {
this.id = id;
this.name = name;
}



i reverted the code back to how it was in the tutorial (where the topmost class had only 1 attribute so i thought it might look different).

then in my unmarshaller i added a 2nd for loop to try to access the Info list , somehow i got the right syntax


for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

for (Info temp : anime.getAnime()){
System.out.println("Info: "+temp.getSrc());
}
}
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 01:53:34
April 16 2015 01:47 GMT
#12264
+ Show Spoiler [you fixed it] +
private List<Info> Anime = new ArrayList<Info>();

Why is the name of the variable Anime? Do you even need this field? Each Anime having a list of "Info" (whatever that means) seems pretty stupid in the first place. If you need more fields you can create them and call them things that actually make sense. You'd want to add fields for say release date or author rather than creating a list of Info.


I really dislike the idea of this Info class, but if it works then I won't rain on your parade.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:59:28
April 16 2015 01:53 GMT
#12265
i'm using Info because its one of the XML tags... it occurs dozens of times for each anime entry with just random different info in:

- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
etc


so i'm currently saving everything in an info tag into an Info object


@XmlRootElement (name="info")
public class Info {

private String src;

@XmlAttribute(name="src")
public String getSrc() {
return src;
}


and taking the @XmlAttribute from each info entry (if it exists) (only 1 exists per anime and i only need the 1, so that's handy) and accessing it with info.getSrc

right now i'm getting....

[image loading]

which is basically "HOLY FUCK I DONE IT AND SO FAST LOL OMFG TNX TUTORIAL also tnx brain and planning on paper lol"

btw is it normal for netbeans to ramp up to 1,300,000 memory lol

look lol

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 02:05:16
April 16 2015 01:58 GMT
#12266
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


Well each of those Info objects is at least 20 bytes and then you have a ton of them per parse so...

catch (Exception e)


My eyes are bleeding. I guess if you're just going to print the message then maybe it doesn't matter, but ^_^
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 02:36:54
April 16 2015 02:05 GMT
#12267
what i would delete that shit but it probably goes all red

i'm going to use the data to populate a webpage frontend for the user and also save it to a local database or do something else with it

i guess my next task is to go figure out the API get request so it doesn't look like a complete hackjob




i have a sort of interesting question .... how would i describe what this is doing in non-retard terms? for example i am trying to describe it like:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 02:47 GMT
#12268
I'm pretty bad at jargon too, so can't really help you there . It's basically a practice thing.

Also, you seem to over-complicating things by having an Info class. If the data is stored like this:
<anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>
</anime>


Then you should be parsing the type field in the info tags, and then pass the value into a variable in the Anime class. Basically, your class should look something like this:
class Anime{
private string title;
private string altTitle;
private string genre;
private List<string> themes; //assuming >1 theme is possible, otherwise just a single string
private double runTime;
}
Average means I'm better than half of you.
phar
Profile Joined August 2011
United States1080 Posts
April 16 2015 03:05 GMT
#12269
^^ strongly agree with using separate fields for things instead of just generic repeated info

You can heave a repeated info for unknown info tags if you want, but try to get more stuff parsed in up front, it's more useful.
Who after all is today speaking about the destruction of the Armenians?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 03:07:43
April 16 2015 03:06 GMT
#12270
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 03:21:46
April 16 2015 03:19 GMT
#12271
i'm not sure if that is possible

the way i am doing it is

look at @XmlRootElement (name="info")
look at @XmlAttribute(name="src")
save this


if there is an xml parser functionality that lets me check for Picture inside Infos then take the corresponding SRC from that Info and put it straight into Anime then sure....but i don't know if @XmlAttribute or @Something exists to do that

if anything there might be a plugin that lets you do that, like it autoscans the document and returns X for your nomatter where X is located...........

there is no fucking way i'm getting into that though :D i've got 4 days to finish this and then 4 days to do 2 other major assignments . edit: unless there is @functionality that just does that.............
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
April 16 2015 03:23 GMT
#12272
On April 16 2015 12:06 Blitzkrieg0 wrote:
Show nested quote +
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.


i was just describing the "prototype version" for when i have to write about it and sound mildly technical or whatever
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 03:29 GMT
#12273
Well, can't help you with the specifics because I haven't used JAXB before. That said, this is the part where you learn that your power to Google is what makes you a programmer :D.
Average means I'm better than half of you.
ArchmageKruzer
Profile Joined August 2013
64 Posts
April 16 2015 03:43 GMT
#12274
So a couple of my friends and I want to make an IOS game. Currently we're writing the code in Java and then we're gonna import it into IOS. My question is is this a good idea, and if so, do you have any tricks and stuff to make the import easier, since there are probably gonna be like a million things going wrong once we do it.
Also, i've been poking around for engines, and 5 mins of google got me to the Unreal engine, which seems pretty OK. Any engine suggestions for IOS games, and tips/tutorials on how to use them?
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 13:17:07
April 16 2015 04:30 GMT
#12275
+ Show Spoiler +
(ignore this bit)
+ Show Spoiler +
so apparently you don't need to use REST web services, you can just have

URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~neon genesis" );

Ann ann = (Ann) ums.unmarshal(url);

and it does the get request and puts it straight into your parser. wtf. that is insane
i just shaved like 40 years off my life


i think i move on to figuring out how to make it into MVC now with a basic web frontend and then add a database functionality and then add jquery stuff



question about what i do next:

am i supposed to have the anime classes as managed java beans or can i keep them as they are and just print the data to a jsp page via a servlet controller?

ive been fucking around for a while and ended up with an insane mess and getting no error but it just fails to run with no error specification . at one point i tried to add bean annotations ontop of the xml annotations but it gave me a frowny face and i backed off for the time being

this is what i've got in my head so far:
1) jsp frontend page that takes the user's search string in a form
2) servlet page that takes this and passes it to my service class
3) the service class does GET request and parses the response into the anime objects
4) but then how do i access this data ? does it need to be turned into a java managed bean? can i access it directly from the jsp page? does it need to go through the servlet controller?

ill come back in 8 hours or whatever after i slept

have been trying random stuff but there's tons of stuff to try and that's before i even go to one of the super heavy tutorials .

edit: maybe i make session facade bean from the Ann java class and then use that to do stuff. if it lets me annotate it



OK here is what i've got so far. it runs , time-outs for about 9 seconds, then displays the HTML ("end") ie it doesnt display the object data

ControllerServlet.java
+ Show Spoiler +


ControllerServlet.java

package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

@EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB.Unmarshalling("evangelion");

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}


AnnJAXB.java
+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public static void Unmarshalling(String searchString) {
try {

JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );

Ann ann = (Ann) ums.unmarshal(url);


} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}



when i remove the line AnnJAXB.Unmarshalling("evangelion"); it runs and displays the html instantly, so that bit there is causing it to time out and return nothing from it.

the obvious problem is in AnnJAXB at the line

Ann ann = (Ann) ums.unmarshal(url);

for this it says Variable ann is not used

the other bit that looks weird is
 @EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();
bit


posted to stackoverflow, easier to read http://stackoverflow.com/questions/29674404/mvc-object-method-and-serlvet-structure-help-in-java-please


i tried changing AnnJAXB Unmarshall to return an Ann instead of being static void method. i managed to get it to work eventually but its still hanging like previous version then not displaying the object data.

controllerservlet
+ Show Spoiler +


package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
*
* @author J
*/
@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

// @EJB
// private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann;

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB an = new AnnJAXB();
try{
an.Unmarshalling("evangelion");
}catch(Exception e){}

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}



annjaxb

+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public Ann Unmarshalling(String searchString) throws JAXBException, MalformedURLException {


JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );


Ann ann = (Ann) ums.unmarshal(url);

return ann;
}
}



i have no words

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Manit0u
Profile Blog Joined August 2004
Poland17386 Posts
April 16 2015 19:25 GMT
#12276
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


*reads the word "netbeans"*

*averts his eyes*
Time is precious. Waste it wisely.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 22:38:54
April 16 2015 22:38 GMT
#12277
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-04-16 23:06:49
April 16 2015 23:06 GMT
#12278
On April 17 2015 07:38 FFGenerations wrote:
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min


Are those your only 3 classes in SO. It's kind of hard to troubleshoot code without being able to run it. Did someone already talk to you about possibly putting your stuff on github or something if you want more help?

Edit: Definitely not your only 3 classes. See question above
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:16:17
April 16 2015 23:15 GMT
#12279
hey dude, here is a zip file with the project (if google drive lets you share zipped code)

https://drive.google.com/file/d/0BzIvzoW04fGQbUdMT3RYVXN5ODA/view?usp=sharing


i got stuck trying to get git to work a while back and havent tried to use it since. i will sort that out sometime
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:34:05
April 16 2015 23:26 GMT
#12280
STOP I FIXED IT HOLY FUCKING CHRIST


I changed the loop to say:
+ Show Spoiler +

 for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {


and removed

 annj.Unmarshalling("evangelion");


so it looks like


try{
for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {

out.println("<h1>Loop1</h1>");

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}}catch(Exception e){}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");


pic

+ Show Spoiler +

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Prev 1 612 613 614 615 616 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 2h 39m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 64
OGKoka 58
StarCraft: Brood War
firebathero 809
sSak 605
Larva 298
PianO 232
Soma 113
Killer 74
Sharp 47
soO 40
HiyA 12
Bale 4
[ Show more ]
Britney 0
Dota 2
XaKoH 406
XcaliburYe130
ODPixel34
Counter-Strike
shoxiejesuss842
olofmeister628
Coldzera 363
allub221
Super Smash Bros
Mew2King97
Other Games
summit1g8820
C9.Mang0478
ceh9450
Tasteless218
Pyrionflax113
rGuardiaN28
Trikslyr21
Organizations
Other Games
gamesdonequick710
Counter-Strike
PGL420
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH187
• LUISG 12
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• HappyZerGling138
Upcoming Events
Wardi Open
2h 39m
Wardi Open
6h 9m
PiGosaur Monday
15h 39m
Replay Cast
1d 1h
Tenacious Turtle Tussle
1d 14h
The PondCast
2 days
OSC
2 days
WardiTV Invitational
3 days
Online Event
3 days
RSL Revival
3 days
[ Show More ]
RSL Revival
4 days
WardiTV Invitational
4 days
Afreeca Starleague
4 days
Snow vs Soma
Sparkling Tuna Cup
5 days
WardiTV Invitational
5 days
CrankTV Team League
5 days
RSL Revival
5 days
Wardi Open
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.